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) 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 @@
- +
-
+
+ +
+
-
+
-
+
-
- -
- +
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 + 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):