Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions GroupTagCloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@
import time
import logging
import jieba
import numpy as np
from PIL import Image

class GroupTagCloud(ProcessInterface):
recordMaxNum = 500
maxFrequency = 40
imgDir = 'TagCloud'

def __init__(self, fontPath):
def __init__(self, fontPath, maskPath = None):
self.client = MongoClient()
self.coll = self.client[dbName][collName]
self.fontPath = fontPath
self.wordCloud = WordCloud(font_path=self.fontPath, width=400, height=400, max_words=100)
if maskPath is None:
self.wordCloud = WordCloud(font_path=self.fontPath, width=400, height=400, max_words=100)
else:
self.mask = np.array(Image.open(maskPath))
self.wordCloud = WordCloud(font_path=self.fontPath, mask=self.mask, max_words=100)
if not os.path.exists(self.imgDir):
os.mkdir(self.imgDir)
logging.info('GroupTagCloud connected to MongoDB.')
Expand Down
Binary file added girl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
GlobalTextHook({ '^ding$': 'dong', '鸭哥': '嘎?' }),
PaiDuiHook(),
HistoryRecorder(),
GroupTagCloud('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc'),
GroupTagCloud('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc','girl.png'),
ActivityInfo('/usr/share/fonts/truetype/wqy/wqy-microhei.ttc'),
GroupMessageForwarder([ '二群', '三群' ], [ 'AI二群测试中', 'AI三群测试' ])
]
Expand Down