import jieba
from scipy.misc import imread
from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator
import matplotlib.pyplot as plt
import pandas as pd
def get_word():
df = pd.read_csv('weixiaobao_data/wen.txt', sep='\t')
word_list = df['MsgTitle'].tolist()
return word_list
def get_word_list(mylist):
word_list = [' '.join(jieba.cut(sen)) for sen in mylist]
new_text = ' '.join(word_list)
pic_path = 'buity.jpg'
im_mask = imread(pic_path)
wordcloud = WordCloud(background_color='white',
font_path=r'C:\Windows\Fonts\simfang.ttf',
mask=im_mask,
stopwords=STOPWORDS).generate(new_text)
plt.imshow(wordcloud)
plt.axis('off')
plt.show()
wordcloud.to_file('ciyun.jpg')
word_list = get_word()
get_word_list(word_list)
利用jieba进行分词,词云图展示
最新推荐文章于 2024-06-08 15:52:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)