def get_word_to_cloud(self):
for file in self.file_list:
with codecs.open('../spider/' + file, "r",encoding='utf-8', errors='ignore') as string:
#??????????????????
string = string.read().upper()
#???????????
res = jieba.cut(string, HMM=False)
reslist = list(res)
wordDict = {}
#???????????
for i in reslist:
if i not in self.dic_list:
continue
if i in wordDict:
wordDict[i]=wordDict[i]+1
else:
wordDict[i] = 1
#???????
coloring = imread('test.jpeg')
#???????????????
wc = WordCloud(font_path='msyh.ttc',mask=coloring,
background_color="white", max_words=50,
max_font_size=40, random_state=42)
wc.generate_from_frequencies(wordDict)
#????
wc.to_file("%s.png"%(file))
#???????
data_desc_process.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录