Update analysis.py

词云分开统计:“我”说的最多和“TA”说的最多,而不是“我们”说的最多
This commit is contained in:
Xinghe 2023-12-13 19:26:06 +08:00 committed by GitHub
parent 219a66ccff
commit 77442552cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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