更新数据截止日2026.01.08
This commit is contained in:
1949
word/stopwords.txt
Normal file
1949
word/stopwords.txt
Normal file
File diff suppressed because it is too large
Load Diff
92
word/userdict.txt
Normal file
92
word/userdict.txt
Normal file
@@ -0,0 +1,92 @@
|
||||
抱拳 10 n
|
||||
OK 10 n
|
||||
破涕为笑 10 n
|
||||
玫瑰 10 n
|
||||
撇嘴 10 n
|
||||
擦汗 10 n
|
||||
捂脸 10 n
|
||||
偷笑 10 n
|
||||
呲牙 10 n
|
||||
发呆 10 n
|
||||
疑问 10 n
|
||||
微笑 10 n
|
||||
握手 10 n
|
||||
苦涩 10 n
|
||||
合十 10 n
|
||||
脸红 10 n
|
||||
旺柴 10 n
|
||||
社会社会 10 n
|
||||
|
||||
2024年 3 n
|
||||
2025年 3 n
|
||||
1月 3 n
|
||||
2月 3 n
|
||||
3月 3 n
|
||||
4月 3 n
|
||||
5月 3 n
|
||||
6月 3 n
|
||||
7月 3 n
|
||||
8月 3 n
|
||||
9月 3 n
|
||||
10月 3 n
|
||||
11月 3 n
|
||||
12月 3 n
|
||||
1日 3 n
|
||||
2日 3 n
|
||||
3日 3 n
|
||||
4日 3 n
|
||||
5日 3 n
|
||||
6日 3 n
|
||||
7日 3 n
|
||||
8日 3 n
|
||||
9日 3 n
|
||||
10日 3 n
|
||||
11日 3 n
|
||||
12日 3 n
|
||||
13日 3 n
|
||||
14日 3 n
|
||||
15日 3 n
|
||||
16日 3 n
|
||||
17日 3 n
|
||||
18日 3 n
|
||||
19日 3 n
|
||||
20日 3 n
|
||||
21日 3 n
|
||||
22日 3 n
|
||||
23日 3 n
|
||||
24日 3 n
|
||||
25日 3 n
|
||||
26日 3 n
|
||||
27日 3 n
|
||||
28日 3 n
|
||||
29日 3 n
|
||||
30日 3 n
|
||||
31日 3 n
|
||||
|
||||
信披 3 n
|
||||
监管员 3 n
|
||||
新系统 5 n
|
||||
新模板 3 n
|
||||
新变化 3 n
|
||||
系统更新 3 n
|
||||
定期报告 3 n
|
||||
回复消息 3 n
|
||||
业务专区 3 n
|
||||
临时公告 3 n
|
||||
填报系统 3 n
|
||||
信披顾问 3 n
|
||||
公告编制系统 3 n
|
||||
|
||||
张瑞婷 3 nr
|
||||
安文辉 3 nr
|
||||
闻举 3 nr
|
||||
小潘 3 nr
|
||||
胡蓉 3 nr
|
||||
刘秋萍 3 nr
|
||||
婷婷 3 nr
|
||||
李婷婷 3 nr
|
||||
致远速联 3 nt
|
||||
|
||||
安文辉 3 n
|
||||
|
||||
|
||||
59
word/word_cloud.py
Normal file
59
word/word_cloud.py
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
import jieba
|
||||
import jieba.posseg as pseg
|
||||
import pandas as pd
|
||||
from wordcloud import WordCloud
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from ..file import LocalFileManager
|
||||
from ..chat_session import ChatSessionManager
|
||||
|
||||
chat_session = ChatSessionManager()
|
||||
data = chat_session.get_chat_history("2025-10-11 00:00:00","2025-10-18 23:59:59")
|
||||
lfm = LocalFileManager("../chat_history")
|
||||
|
||||
# 加载用户词典(使用正确的路径)
|
||||
jieba.load_userdict("../chat_history/userdict.txt")
|
||||
|
||||
# 获取停用词
|
||||
skip_words_content = lfm.get_file("stopwords.txt").decode('utf-8')
|
||||
skip_words = skip_words_content.splitlines() + [" ", '\n']
|
||||
# 生成词频字典(需提前完成分词统计)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
words = {}
|
||||
for i in data:
|
||||
for m in pseg.cut(i[1]):
|
||||
word = m.word
|
||||
flag = m.flag
|
||||
# 正确的比较逻辑:使用word而不是m对象
|
||||
if word not in skip_words and flag not in ["a", "b", "c", "d", "e", "f","r","nrt"] and len(word) > 1:
|
||||
if flag == "eng" and len(word) >= 24:
|
||||
print("skip")
|
||||
else:
|
||||
if word not in words:
|
||||
words[word] = (1,flag)
|
||||
else:
|
||||
words[word] = (words[word][0] + 1,flag)
|
||||
# print("分词结果统计:")
|
||||
# for word, count in sorted(words.items(), key=lambda x: x[1], reverse=True):
|
||||
# print(f"{word}: {count}")
|
||||
df = pd.DataFrame([[word,count[0],count[1]] for word,count in words.items()],columns=["word","count","flag"])
|
||||
df.to_csv("../chat_history/wordcloud.csv",index=False)
|
||||
word_freq = {word:count[0] for word,count in words.items()}
|
||||
# 创建词云对象
|
||||
wc = WordCloud(
|
||||
font_path='msyh.ttc', # 微软雅黑字体文件路径
|
||||
width=800,
|
||||
height=600,
|
||||
background_color='white',
|
||||
max_words=100
|
||||
)
|
||||
# 生成词云
|
||||
wc.generate_from_frequencies(word_freq)
|
||||
# 显示图形
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.imshow(wc, interpolation='bilinear')
|
||||
plt.axis('off')
|
||||
plt.savefig("../chat_history/wordcloud.png")
|
||||
BIN
word/wordcloud.png
Normal file
BIN
word/wordcloud.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 232 KiB |
Reference in New Issue
Block a user