How to do it

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. 

  1. Start by importing the word cloud and the frequency distribution function from NLTK:
from wordcloud import WordCloudfrom nltk.probability import FreqDist
  1. 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 ...

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.