新增个性签名词云
This commit is contained in:
parent
c50a31f814
commit
647f2dc2cc
@ -12,6 +12,8 @@ import os
|
||||
import re
|
||||
import time
|
||||
import shutil
|
||||
from collections import Counter
|
||||
|
||||
import pythoncom
|
||||
import pywxdump
|
||||
|
||||
@ -495,7 +497,51 @@ def get_top_talker_count():
|
||||
@rs_api.route('/api/rs/wordcloud', methods=["GET", 'POST'])
|
||||
@error9999
|
||||
def wordcloud():
|
||||
pass
|
||||
if request.method not in ["GET", "POST"]:
|
||||
return ReJson(1003, msg="Unsupported method")
|
||||
rq_data = request.json if request.method == "POST" else request.args
|
||||
|
||||
try:
|
||||
import jieba
|
||||
except ImportError:
|
||||
return ReJson(9999, body="jieba is required")
|
||||
|
||||
target = rq_data.get("target", "")
|
||||
print(target)
|
||||
if not target:
|
||||
return ReJson(1002, body="target is required")
|
||||
my_wxid = get_conf(g.caf, g.at, "last")
|
||||
if not my_wxid: return ReJson(1001, body="my_wxid is required")
|
||||
db_config = get_conf(g.caf, my_wxid, "db_config")
|
||||
db = DBHandler(db_config)
|
||||
|
||||
if target == "signature":
|
||||
users = db.get_user()
|
||||
signature_list = []
|
||||
for wxid, user in users.items():
|
||||
ExtraBuf = user.get("ExtraBuf", {})
|
||||
signature = ExtraBuf.get("个性签名", "") if ExtraBuf else ""
|
||||
if signature:
|
||||
signature_list.append(signature)
|
||||
signature_str = " ".join(signature_list)
|
||||
words = jieba.lcut(signature_str)
|
||||
words = [word for word in words if len(word) > 1]
|
||||
count_dict = dict(Counter(words))
|
||||
return ReJson(0, count_dict)
|
||||
elif target == "nickname":
|
||||
users = db.get_user()
|
||||
nickname_list = []
|
||||
for wxid, user in users.items():
|
||||
nickname = user.get("nickname", "")
|
||||
if nickname:
|
||||
nickname_list.append(nickname)
|
||||
nickname_str = " ".join(nickname_list)
|
||||
words = jieba.lcut(nickname_str)
|
||||
words = [word for word in words if len(word) > 1]
|
||||
count_dict = dict(Counter(words))
|
||||
return ReJson(0, count_dict)
|
||||
|
||||
return ReJson(1002, body="target is required")
|
||||
|
||||
|
||||
# end 聊天记录分析api ****************************************************************************************************
|
||||
|
@ -46,7 +46,6 @@ class DBHandler(MicroHandler, MediaHandler, OpenIMContactHandler, PublicMsgHandl
|
||||
"""
|
||||
获取联系人列表
|
||||
"""
|
||||
users = self.get_user_list(word=word, wxids=wxids, label_ids=labels)
|
||||
if self.OpenIMContact_exist:
|
||||
users.update(self.get_im_user_list(word=word, wxids=wxids))
|
||||
users = self.get_user_list(word=word, wxids=wxids, label_ids=labels) if self.Micro_exist else {}
|
||||
if self.OpenIMContact_exist: users.update(self.get_im_user_list(word=word, wxids=wxids))
|
||||
return users
|
||||
|
Loading…
Reference in New Issue
Block a user