Constructing word clouds
Word clouds are a nice visualization tool to quickly see topics that are prevalent in a text. They can be used at the preliminary data analysis stage and for illustration purposes. A distinguishing feature of word clouds is that larger-font words signify a more frequent topic, while smaller-font words signify less frequent topics.
After working through this recipe, you will be able to create word clouds from a text and also apply a picture mask on top of the word cloud, which makes for a cool image.
We will use the text of the book The Adventures of Sherlock Holmes and the picture mask we will use is a silhouette of Sherlock Holmes’ head.
Getting ready
We will use the wordcloud
package for this recipe. In order to display the image, we need the matplotlib
package as well. They are both part of the poetry
environment and the requirements.txt
file.
The notebook is located at https://github.com/PacktPublishing/Python-Natural-Language-Processing...