parent
5f7ce6fac1
commit
6a8b985a9c
@ -1,23 +0,0 @@
|
||||
import jieba
|
||||
import wordcloud
|
||||
import imageio
|
||||
#1.读取弹幕数据
|
||||
f =open("总弹幕.txt",encoding='utf-8')
|
||||
text =f.read()
|
||||
#2.分词
|
||||
text_list=jieba.lcut(text)
|
||||
text_str=' '.join(text_list)
|
||||
#3.词云图
|
||||
f2=open("中文常见停用词.text",encoding='utf-8')
|
||||
text2=f2.read().splitlines()#读取弹幕
|
||||
img= imageio.v2.imread('地球.png')#导入词云形状的图片
|
||||
wc=wordcloud.WordCloud(#设置词云格式
|
||||
width=1160,#宽
|
||||
height=800,#高
|
||||
background_color='white',#背景颜色
|
||||
mask=img,#云图样式
|
||||
stopwords=text2,#禁用词
|
||||
font_path='msyh.ttc'#字体
|
||||
)
|
||||
wc.generate(text_str)
|
||||
wc.to_file('词云图.png')
|
Loading…
Reference in new issue