我正在嘗試用 python 中的 matplotlib 做一個詞云,而不是像“will”這樣計算單個單詞,它像“i will”那樣計數兩個。我查看了詞云檔案,似乎沒有任何東西會產生這種情況,我的輸入會導致這種情況嗎?
我的代碼如下所示:
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()
uj5u.com熱心網友回復:
檔案(https://amueller.github.io/word_cloud/generated/wordcloud.WordCloud.html)指出:
搭配:bool,默認值=True
是否包含兩個詞的搭配(bigrams)。如果使用 generate_from_frequencies,則忽略。
您可能需要在 WordCloud 的引數中包含 collocations=False。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/396828.html
標籤:Python 数据框 matplotlib
上一篇:物理學中的高斯曲線擬合
