|
|
|
@ -0,0 +1,22 @@
|
|
|
|
|
import wordcloud
|
|
|
|
|
import jieba
|
|
|
|
|
from matplotlib import pyplot as plt
|
|
|
|
|
from wordcloud import WordCloud, ImageColorGenerator
|
|
|
|
|
from PIL import Image
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
#爬不到很多关于ai的数据,用所有数据完成数据可视化
|
|
|
|
|
f= open('D:\danmucrawler\danmupapa\danmu.txt',encoding='utf-8')
|
|
|
|
|
text=f.read().encode('utf-8').decode('utf-8')
|
|
|
|
|
print(text)
|
|
|
|
|
llist=jieba.lcut(text)
|
|
|
|
|
|
|
|
|
|
string=''.join(llist)
|
|
|
|
|
wc=wordcloud.WordCloud(
|
|
|
|
|
width=1000, height=500, background_color='white', font_path='msyh', scale=15
|
|
|
|
|
)
|
|
|
|
|
wc.generate(string)
|
|
|
|
|
wc.to_file('ciyun1.png')
|
|
|
|
|
plt.imshow(wc, interpolation='bilinear')
|
|
|
|
|
plt.axis("off")
|
|
|
|
|
plt.show()
|