-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd069ab
commit 9abaabc
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |