Skip to content

Commit

Permalink
Modi word map
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat2430 committed Jan 26, 2021
1 parent bd069ab commit 9abaabc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions modimap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Read the whole text.
f = open(r'./np3.txt', "r")
text = f.read()

# Read the mask image
modi_coloring = np.array(Image.open('../input/modipic/narendramodi-pti.jpg'))
stopwords = set(STOPWORDS)

# Set up word cloud
wc = WordCloud(max_words=1500, mask=modi_coloring, stopwords=stopwords, max_font_size=35, random_state=42)

# Generate word cloud
wc.generate(text)

# Create coloring from image
image_colors = ImageColorGenerator(modi_coloring)

# Show image
plt.figure(figsize = (15, 15))
plt.axis('off')
plt.imshow(wc.recolor(color_func=image_colors), interpolation="bilinear")

0 comments on commit 9abaabc

Please sign in to comment.