yytxdy
import jieba.analyse as analyse
import matplotlib.pyplot as plt
from wordcloud import WordCloud

data = open(\'data.txt\', \'rt\', encoding=\'utf-8\').read()
tags = analyse.extract_tags(data, topK=20, withWeight=True, allowPOS=())
word_frequence = {tag[0]: tag[1] for tag in tags}
wordcloud = WordCloud(font_path="data/simhei.ttf", background_color="white", max_font_size=80)
wordcloud = wordcloud.fit_words(word_frequence)
plt.imshow(wordcloud)
plt.show()
wordcloud.to_file(\'data.jpg\')

  

分类:

技术点:

相关文章: