Entries from 2024-03-01 to 1 month
When conducting data analysis, deciding on the unit for aggregating data is crucial. Currently, in the midst of analyzing data obtained from bulk email collection, it seems beneficial to aggregate the data on a weekly basis. Here's a sampl…
データ分析する時に、 どの単位でデータをまとめるか。 メールの一括収集でできるデータ分析を している最中ですが、 週ごとにメールをまとめるのが よさそうでした。 これはサンプル。 dataは2次元配列として準備、 1要素目が日付、 2要素目が本文のサンプ…
When decoding UTF-8 text, it is being detected as Windows-1254, resulting in garbled characters. detect_enc = chardet.detect(temp)['encoding'] In that case, you can add an additional condition to handle the case when the text is mistakenly…
UTF-8のテキストをデコードする時に、 Windows-1254と判定され、文字化けする現象。 detect_enc = chardet.detect(temp)['encoding'] 仕方ないので、条件分岐をひとつ増やして対応。 elif detect_enc == 'Windows-1254': detect_enc = 'utf-8' html_content …
I think you can follow this flow to prepare for the data analysis with python. Once you reach the TextAnalyzer, various statistical analyses can be conducted.
こんな流れで読み込んでいけばいいと思います。 TextAnalyzerまで到達すれば、あとは各種分析が実施可能です。
Previously, I posted a web scraping example using urllib, but it becomes difficult to handle when there is a session involved. Using Selenium to utilize a browser makes it easier to handle sessions. In the following sample: You set URL, XP…
以前、urllibを使ったWebスクレイピング例を投稿したが、 セッションがあると、扱うのが難しくなってくる。 Seleniumを使って、ブラウザを利用すると、 セッションが扱いやすくなる。 以下サンプルでは、 xpath_listに、URL、XPATH、検索文字列、を設定する…
I've modularized the previous version of the email fetching script, focusing solely on message retrieval. I omitted the decoding and content processing, leaving those tasks to be handled in the main processing script if needed. I've also a…
前回のメール逐次取得版をモジュール化しました。 今回は、メッセージの取得だけに特化し、 デコード処理やコンテンツ処理は省略しました。 それらの処理が必要な場合は、メイン処理側で対応すること。 モジュールのドキュメンテーションも追加。 以下のコー…
As mentioned in a previous article, when you use the conventional python library method of fetching mailboxes, it seems that parsing the entire file is required, so it can take a considerable amount of time. import mailbox mbox = mailbox.m…
通常のmailbox取得では、ファイルの全体をパース指定するようで、 とても時間がかかることは以前の記事に書いた。 import mailbox mbox = mailbox.mbox('example.mbox') for message in mbox: print("Subject:", message['subject']) mbox.close() 逐次的に…
With the web scraping method, you may want to collect a large amount of data independently and automate the collection. The most important thing is whether the website allows web scraping or not. You can find out by looking at the contents…
Webスクレイピングで、 たくさんのデータを独自に収集して、 収集を自動化したい。 一番大事なのは、 サイト側がWebスクレイピングを許可しているかどうか。 サイトの ルートディレクトリにある 「robots.txt」の中身を見てみることで分かる。 https://www.y…
Assuming there is a file named "category_social.mbox" in the same folder, the following Python script counts the frequency of term occurrences using CountVectorizer, only for emails with the word "follow" in their titles. This serves as a …
同じフォルダに「category_social.mbox」があると仮定して、 タイトルにワード「フォロー」が含まれているメールのみ、 CountVectorizerで語句の出現頻度を集計するPythonスクリプトです。 AIや機械学習処理の前準備になる部分です。 今回はメール読み込みで…
Here are the minimum preprocessing steps required when performing text analysis in Python: Read the text Tokenize the text Count the tokenized words Below is a sample: First, prepare the data. Refer to a Wikipedia Japanese page and store i…
Pythonでテキスト分析する時に最低限必要な前処理を記載します。 ・テキストを読み込む ・分かち書きする ・分かち書きした語句をカウントする 以下サンプルです。 まずは、データの準備です。 Wikipedia日本語版のページを参照し、 test_dir/isaac_asimov_w…
When performing Japanese natural language processing in Python,I borrowed wisdom from senior bloggers, so I managed to create a process for tokenization using MeCab. I'll paste the source code at the end of this article. As a FYI in this b…
Pythonで自然言語処理を行うにあたり、 ブログの諸先輩方から知恵を借りて、 Mecabで分かち書きする処理を作成。 この記事の末尾にソースを貼り付けておく。 このブログでの注意点として「self.tagger.parse("")」を追加。 これがないと、不定値の解析結果が…
Since there is limited information available online, I'll provide it here. My family has been using the ASUS EEBOOK X205TA for several years, but suddenly the battery stopped charging. (This model has always been somewhat unstable.) Even w…
Webに情報が少なかったので、載せておきます。 家族がASUS EEBOOKのX205TAを数年間使っていますが、 突然バッテリの充電が突然できなくなりました。 (この機種は、ずっとイマイチ安定しない) AC電源をつないでも、充電ランプが点灯せず、 バッテリがなくな…
'cp932' codec can't encode character '©' in position 3337: illegal multibyte sequence Exception commonly encountered when running Python on Japanese version of Windows, but almost never observed on Linux. Verify the point below before delv…
'cp932' codec can't encode character '\xa9' in position 3337: illegal multibyte sequence Windowsで、Pythonを動かすとよく見る例外。Linuxだと見ない。 エンコード・デコードの深みを調査する前に、これを確認すること。 自分への備忘録。 スタックト…
With a tendency to forget things often, I've decided to open a blog to keep future memos. Over the past decade or so, my Gmail account has accumulated a lot of emails, mostly advertisements and newsletters. With such a large collection, I …
Memo on decoding the email header. Using the sender/from address as an example. from email.header import decode_header decoded = decode_header(message['from']) outstr = decoded[0][0].decode(decoded[0][1]) # sample: decoded[0][0] # b'Linked…
メールヘッダーのデコード部分の備忘録。 送信元を例に。 from email.header import decode_header decoded = decode_header(message['from']) outstr = decoded[0][0].decode(decoded[0][1]) # 例)decoded[0][0] # b'LinkedIn\xe3\x82\xb3\xe3\x83\xb3\xe3…
物忘れが多く、今後の備忘録を書くためにブログを開設。 ここ10年ぐらいのメールがGmailにたまっている。 ほとんど広告やニュースレターだが、これだけたくさん溜まっていると、 時代ごとに何か面白い傾向でも見つかるかと、Pythonで分析したく思った。 Gmai…