Wordcloud使用短语而不是单个单词 [英] Wordcloud use phrases rather than single words

查看:442
本文介绍了Wordcloud使用短语而不是单个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为单个单词生成wordcloud图像,效果很好。我想为短语生成图像。


并显示以下消息:


未绘制以下单词:


非常难的短语(13)


为了使这些单词出现在您的
云中,请缩小单词云或降低这些$ b $的频率单词列表中的b个单词。


以编程方式进行同样的操作。


I am generating a wordcloud image for single word and that works out fine. I want to generate the image for phrases. Their documentation states in the very first question that for 2 word phrases I need to use ~ to link them. I've tried this method linking my n lenght phrases but it still takes only 2 words in to consideration.

Is this the limit or there is a way to generate wordcloud with more than 2 word phrases?


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()

解决方案

It seems to have more to do with fitting the phrases into the cloud... if you play with https://www.wordclouds.com/ you can see that if a term is long AND frequent, the algorithm will have trouble to add into the cloud.

If you put a large concatenated word in the page, you may see this message in the corner:

with the following message:

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.

The same goes for doing it programaticaly.

这篇关于Wordcloud使用短语而不是单个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆