mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 10:52:18 +08:00
commit
48830a648c
@ -17,7 +17,7 @@ wordcloud_width = 780
|
|||||||
wordcloud_height = 720
|
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
|
import jieba
|
||||||
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, is_Annual_report, year)
|
txt_messages = msg_db.get_messages_by_type(wxid, MsgType.TEXT, is_Annual_report, year)
|
||||||
if not txt_messages:
|
if not txt_messages:
|
||||||
@ -27,7 +27,9 @@ def wordcloud(wxid, is_Annual_report=False, year='2023'):
|
|||||||
'max_num': "0",
|
'max_num': "0",
|
||||||
'dialogs': []
|
'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)
|
total_msg_len = len(text)
|
||||||
# 使用jieba进行分词,并加入停用词
|
# 使用jieba进行分词,并加入停用词
|
||||||
words = jieba.cut(text)
|
words = jieba.cut(text)
|
||||||
|
@ -63,22 +63,22 @@
|
|||||||
<iframe src="/home" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
<iframe src="/home" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div id="page2" class="page">
|
<div id="page2" class="page">
|
||||||
<iframe src="/wordcloud" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
<iframe src="/wordcloud/1" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div style="background-color: #8a6d3b" id="page3" class="page">
|
<div id="page3" class="page">
|
||||||
|
<iframe src="/wordcloud/0" frameborder="0" height="100%" width="100%" class="if00"></iframe>
|
||||||
|
</div>
|
||||||
|
<div style="background-color: #8a6d3b" id="page4" class="page">
|
||||||
<iframe src="/test" frameborder="0" id="iframe0" height="100%" width="100%" class="if00"></iframe>
|
<iframe src="/test" frameborder="0" id="iframe0" height="100%" width="100%" class="if00"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div style="background-color: #337ab7" id="page4" class="page">
|
<div style="background-color: #337ab7" id="page5" class="page">
|
||||||
<iframe src="test" frameborder="0" id="iframe3" height="100%" width="100%" class="if00"></iframe>
|
<iframe src="test" frameborder="0" id="iframe3" height="100%" width="100%" class="if00"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div style="background-color: #337ab7" id="page5" class="page">
|
<div style="background-color: #337ab7" id="page6" class="page">
|
||||||
<iframe src="test" frameborder="0" id="iframe4" height="100%" width="100%" class="if00"></iframe>
|
<iframe src="test" frameborder="0" id="iframe4" height="100%" width="100%" class="if00"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div style="background-color: #337ab7" id="page6" class="page">
|
|
||||||
<iframe src="test" frameborder="0" id="iframe5" height="100%" width="100%" class="if00"></iframe>
|
|
||||||
</div>
|
|
||||||
<div style="background-color: #337ab7" id="page7" class="page">
|
<div style="background-color: #337ab7" id="page7" class="page">
|
||||||
<iframe src="test" frameborder="0" id="iframe6" height="100%" width="100%" class="if00"></iframe>
|
<iframe src="test" frameborder="0" id="iframe5" height="100%" width="100%" class="if00"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<div class="bg f-page"></div>
|
<div class="bg f-page"></div>
|
||||||
<div class="tt f-animOpac" style="font-size:30px !important">
|
<div class="tt f-animOpac" style="font-size:30px !important">
|
||||||
<h1>二零二三</h1>
|
<h1>二零二三</h1>
|
||||||
<h1>你说的最多的是</h1></div>
|
<h1>{{ who }}说的最多的是</h1></div>
|
||||||
<div class="ckeywords j-anim01 z-anim">
|
<div class="ckeywords j-anim01 z-anim">
|
||||||
<div class="hands">
|
<div class="hands">
|
||||||
<div class="hand2"></div>
|
<div class="hand2"></div>
|
||||||
@ -96,4 +96,4 @@
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -34,15 +34,17 @@ def home():
|
|||||||
return render_template('home.html', **data)
|
return render_template('home.html', **data)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/wordcloud')
|
@app.route('/wordcloud/<who>/')
|
||||||
def one():
|
def one(who):
|
||||||
wxid = contact.wxid
|
wxid = contact.wxid
|
||||||
# wxid = 'wxid_lltzaezg38so22'
|
# 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:
|
with open('wordcloud.html', 'w', encoding='utf-8') as f:
|
||||||
f.write(render_template('wordcloud.html', **world_cloud_data))
|
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):
|
def set_text(text):
|
||||||
|
Loading…
Reference in New Issue
Block a user