在用wordcloud生成词云时,总会生成不需要的词如“笑道,道,说”
尝试使用改变分词模式效果依旧不明显
有无更好的办法去除这种无用的动词呢?
以下是我用的代码:
import jieba
import wordcloud
from imageio import imread
mk=imread("pf.png")
f = open("红楼梦.txt", "r", encoding="utf-8" )
excludes={"说道","分节阅读","说","笑道","说着","宝玉听了","一面说","贾母笑道",
"手机电子书","大学生阅读网","大学生小说网","更新时间","本章字数",
"正说着","袭人道","宝玉笑道","说毕"}
t = f.read( )
f. close( )
#分词模式
ls = jieba.lcut(t)
txt ="".join(ls)
W = wordcloud.WordCloud(font_path = "msyh.ttc",
width = 1000, height = 700,
background_color = "white",
max_words=9,
stopwords=excludes,
mask=mk)
W. generate(txt)
W.to_file( "词云.png")