How to create a word cloud from a corpus?
Wordcloud is the pictorial representation of the most frequently repeated words representing the size of the word.
Wordcloud
import nltk from nltk.corpus import webtext from nltk.probability import FreqDist from wordcloud import WordCloud import matplotlib.pyplot as plt nltk.download('webtext') wt_words = webtext.words('testing.txt') # Sample data data_analysis = nltk.FreqDist(wt_words) filter_words = dict([(m, n) for m, n in data_analysis.items() if len(m) > 3]) wcloud = WordCloud().generate_from_frequencies(filter_words) # Plotting the wordcloud plt.imshow(wcloud, interpolation="bilinear") plt.axis("off") (-0.5, 399.5, 199.5, -0.5) plt.show()
2019-05-03T17:21:01+05:30
2019-05-03T17:21:01+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution