Wordcloud 使用短语而不是单个单词

Wordcloud use phrases rather than single words

我正在为单个词生成词云图像,效果很好。我想为短语生成图像。 Their documentation states in the very first question 对于 2 个单词短语,我需要使用 ~ 到 link。我试过这种方法 linking 我的 n 长短语,但它仍然只需要考虑 2 个单词。

这是限制还是有办法生成包含 2 个以上词组的词云?


wordcloud = WordCloud(
    width=1000,
    height=1000,
    background_color='black',
    stopwords=STOPWORDS).generate(str(text))
fig = plt.figure(
    figsize=(10, 10),
    facecolor='k',
    edgecolor='k')
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.tight_layout(pad=0)
plt.show()

这似乎与将短语拟合到云中有更多关系......如果你玩 https://www.wordclouds.com/ 你会发现如果一个词又长又频繁,算法将难以添加进入云端。

如果您在页面中放置一个大的串联词,您可能会在角落看到这条消息:

带有以下消息:

The following words were not drawn:

very long phrase hard (13)

In order to make these words appear in your cloud, either shrink the word cloud, or lower the frequency of these words in the word list.

编程方式也是如此。