Skip to content
Advertisement

Less Frequent Words appearing bigger – WordCloud in Python

I have been plotting the wordcloud using the wordcloud package from Python. Here’s a sample of the code:

JavaScript

enter image description here

Now, what I understood from the official documentation of Wordcloud is that, most frequent non-stop words appear to be bigger, but here chirping is appearing than Bengal. But then when I check out the frequency of chirping:

JavaScript

And now, when I check the frequency of Bengal:

JavaScript

“Bengal” is appearing small in “yellow” color just below the word “Part” left of “Trekking”. Now I’m not able to understand why is that happening, or how I can fix that. Also I want to know is there a way to remove prepositions from wordcloud, like at, beside, inside, etc.

Is there a way I can assign weightage or frequency and then plot the wordcloud?

Advertisement

Answer

Can you post a sample output of the ‘data’ variable? It might be possible that the entire text while passing it to the canvas object.

You can assign weightage based on the frequency of the words in a text using getFrequencyDictForText() API to get the frequency of the text and makeImage() to generate the canvas.

Please refer to the API documentation here: https://amueller.github.io/word_cloud/auto_examples/frequency.html#sphx-glr-auto-examples-frequency-py

Advertisement