单词云计算两个单词而不是一个



我正试图用python中的matplotlib做一个单词云,而不是计算像"将";其计数为两个类似";我会的";。我看过云文档这个词,似乎没有任何东西能产生这种情况,我的输入会导致这种情况吗?

我的代码如下:

fields = ['comments']
text= pd.read_csv('comments.csv', usecols=fields)
stopwords = ["https", "RT"] + list(STOPWORDS)
print(' '.join(text['comments'].tolist()))
wordcloud = WordCloud(stopwords=stopwords, background_color="white").generate(' '.join(text['comments'].tolist()))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()

文档(https://amueller.github.io/word_cloud/generated/wordcloud.WordCloud.html)状态:

搭配:bool,default=True

是否包括两个单词的搭配(bigrams(。如果使用generate_from_frequency,则忽略。

您可能需要在WordCloud的参数中包含collocations=False。

最新更新