From 219a66ccff8b41484cd966c52d8ba01c94332cf9 Mon Sep 17 00:00:00 2001 From: Xinghe <62918118+XingHehy@users.noreply.github.com> Date: Wed, 13 Dec 2023 19:24:05 +0800 Subject: [PATCH 1/4] Update web.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 词云分开统计:“我”说的最多和“TA”说的最多,而不是“我们”说的最多 --- app/web_ui/web.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/web_ui/web.py b/app/web_ui/web.py index 37e7d49..77e8b7d 100644 --- a/app/web_ui/web.py +++ b/app/web_ui/web.py @@ -34,15 +34,17 @@ def home(): return render_template('home.html', **data) -@app.route('/wordcloud') -def one(): +@app.route('/wordcloud//') +def one(who): wxid = contact.wxid # wxid = 'wxid_lltzaezg38so22' - world_cloud_data = analysis.wordcloud(wxid) - + # print('wxid:'+wxid) + world_cloud_data = analysis.wordcloud(wxid,who=who) # 获取与Ta的对话数据 + # print(world_cloud_data) + who = "你" if who == '1' else "TA" with open('wordcloud.html', 'w', encoding='utf-8') as f: f.write(render_template('wordcloud.html', **world_cloud_data)) - return render_template('wordcloud.html', **world_cloud_data) + return render_template('wordcloud.html', **world_cloud_data,who=who) def set_text(text): From 77442552cd36bf89b2a24f0101a1f50046b8e909 Mon Sep 17 00:00:00 2001 From: Xinghe <62918118+XingHehy@users.noreply.github.com> Date: Wed, 13 Dec 2023 19:26:06 +0800 Subject: [PATCH 2/4] Update analysis.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 词云分开统计:“我”说的最多和“TA”说的最多,而不是“我们”说的最多 --- app/analysis/analysis.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/analysis/analysis.py b/app/analysis/analysis.py index 430179d..5eb13fe 100644 --- a/app/analysis/analysis.py +++ b/app/analysis/analysis.py @@ -17,7 +17,7 @@ wordcloud_width = 780 wordcloud_height = 720 -def wordcloud(wxid, is_Annual_report=False, year='2023'): +def wordcloud(wxid, is_Annual_report=False, year='2023', who='1'): import jieba txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, is_Annual_report, year) if not txt_messages: @@ -27,7 +27,9 @@ def wordcloud(wxid, is_Annual_report=False, year='2023'): 'max_num': "0", 'dialogs': [] } - text = ''.join(map(lambda x: x[7], txt_messages)) + # text = ''.join(map(lambda x: x[7], txt_messages)) + text = ''.join(map(lambda x: x[7] if x[4] == int(who) else '', txt_messages)) # 1“我”说的话,0“Ta”说的话 + total_msg_len = len(text) # 使用jieba进行分词,并加入停用词 words = jieba.cut(text) From de3afb3989714acfde13d1b0a4284b53909fa1a6 Mon Sep 17 00:00:00 2001 From: Xinghe <62918118+XingHehy@users.noreply.github.com> Date: Wed, 13 Dec 2023 19:26:57 +0800 Subject: [PATCH 3/4] Update wordcloud.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 词云分开统计:“我”说的最多和“TA”说的最多,而不是“我们”说的最多 --- app/web_ui/templates/wordcloud.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/web_ui/templates/wordcloud.html b/app/web_ui/templates/wordcloud.html index 42ee078..79f9f45 100644 --- a/app/web_ui/templates/wordcloud.html +++ b/app/web_ui/templates/wordcloud.html @@ -32,7 +32,7 @@

二零二三

-

你说的最多的是

+

{{ who }}说的最多的是

@@ -96,4 +96,4 @@ - \ No newline at end of file + From ddcfaf84618a1c20fcad90a58832f2d1de2ebb7c Mon Sep 17 00:00:00 2001 From: Xinghe <62918118+XingHehy@users.noreply.github.com> Date: Wed, 13 Dec 2023 19:27:39 +0800 Subject: [PATCH 4/4] Update index.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 词云分开统计:“我”说的最多和“TA”说的最多,而不是“我们”说的最多 --- app/web_ui/templates/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/web_ui/templates/index.html b/app/web_ui/templates/index.html index 6fcb123..4507f9d 100644 --- a/app/web_ui/templates/index.html +++ b/app/web_ui/templates/index.html @@ -63,22 +63,22 @@
- +
-
+
+ +
+
-
+
-
+
-
- -
- +