Skip to content

Instantly share code, notes, and snippets.

@omarsar
Created August 12, 2018 23:36
Show Gist options
  • Save omarsar/9bf037f32ca66737deb73bcd63d2ecab to your computer and use it in GitHub Desktop.
Save omarsar/9bf037f32ca66737deb73bcd63d2ecab to your computer and use it in GitHub Desktop.
image_file = read_file("1kHhmo4fj5PqhpH2x_hVY6uUDgf2_G0Tn")
# create mask
alice_mask = np.array(Image.open(image_file))
# remove stopwords
stopwords = set(STOPWORDS)
stopwords.add("said")
# generate word cloud
wc = WordCloud(background_color="white", max_words=2000, mask=alice_mask,
stopwords=stopwords)
wc.generate(document)
# plot the word cloud
plt.figure(figsize=(8,6), dpi=120)
plt.imshow(wc, interpolation='bilinear')
plt.axis("off")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment