amueller / word_cloud

A little word cloud generator in Python
https://amueller.github.io/word_cloud
MIT License
10.13k stars 2.32k forks source link

Rank of a word is still taken into account at Relative_scale=1 #507

Open daman01 opened 4 years ago

daman01 commented 4 years ago

I have data of comments and when i am creating a word cloud out of it. It is showing me centre biggest word which has less occurrence but has high rank.

I have tried using the relative_scale option but it didn't worked out for me and instead provided me with less number of results on the word cloud.

The only way i am able to see now is to use wordcloud by frequency which i don't want to opt

Please suggest the solution

for val in df.iterrows():

# typecaste each val to string
val = str(val)

# split the value
tokens = val.split()

# Converts each token into lowercase
for i in range(len(tokens)):
    tokens[i] = tokens[i].lower()

for words in tokens:
    comment_words = comment_words + words + ' '

wordcloud = WordCloud(width=800, height=800, background_color='white', stopwords=stopwords, min_font_size=10,collocations=False).generate(comment_words)

plot the WordCloud image

plt.figure(figsize=(8, 8), facecolor=None) plt.imshow(wordcloud) plt.axis("off") plt.tight_layout(pad=0)

plt.show()

amueller commented 4 years ago

Sorry, I don't understand your question. How can a word have small occurrence but high rank? Can you please provide a minimum example to reproduce?