The script to create the word cloud is in the 08/04_so_word_cloud.py file. This recipe continues on from the stack overflow recipes from chapter 7 to provide a visualization of the data.
- Start by importing the word cloud and the frequency distribution function from NLTK:
from wordcloud import WordCloudfrom nltk.probability import FreqDist
- The word cloud is then generated from the probability distribution of the words we collected from the job listing:
freq_dist = FreqDist(cleaned)wordcloud = WordCloud(width=1200, height=800).generate_from_frequencies(freq_dist)
Now we just need to display the word cloud:
import matplotlib.pyplot as pltplt.imshow(wordcloud, interpolation='bilinear')plt.axis("off")plt.show()
And the resulting ...