问题
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()
回答1:
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.
来源:https://stackoverflow.com/questions/59567124/wordcloud-use-phrases-rather-than-single-words