Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to Issue 274 #703

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions examples/issue274_fully_resolved.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""Issue fully resolved.ipynb

Automatically generated by Colaboratory.

Original file is located at
https://colab.research.google.com/drive/1SLaIz4w3SlGVX55I8PHjo4e-sIIxHfP5
"""

from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
from collections import Counter

"""### Removing "not" from stopwords dictionary and provide that dictionary as an argument to wordcloud api so that it will not get removed by that api"""

stopwords = set(STOPWORDS)
stopwords.remove("not")

words = ["not funny", "funny"]

"""### convert words list to dictionary with values and its occurences and give that as an input to wordcloud api"""

word_could_dict = Counter(words)
wordcloud = WordCloud(width=1000, height=500, stopwords=stopwords).generate_from_frequencies(word_could_dict)

"""### plotted wordcloud using matplotlib"""

plt.figure(figsize=(15, 8))
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
plt.savefig('wordcloud.png', bbox_inches='tight')
plt.close()