10 Chapter 12: Natural Language Processing
In [2]: text = ‘Today is a beautiful day. Tomorrow looks like
bad weather.’
In [3]: blob = TextBlob(text)
In [4]: blob.ngrams()
Out[4]:
[WordList([‘Today’, ‘is’, ‘a’]),
WordList([‘is’, ‘a’, ‘beautiful’]),
WordList([‘a’, ‘beautiful’, ‘day’]),
WordList([‘beautiful’, ‘day’, ‘Tomorrow’]),
WordList([‘day‘, ‘Tomorrow’, ‘looks’]),
WordList([‘Tomorrow’, ‘looks’, ‘like’]),
WordList([‘looks’, ‘like’, ‘bad’]),
WordList([‘like’, ‘bad’, ‘weather‘])]
12.3 Visualizing Word Frequencies with Bar Charts and
Word Clouds
No questions.
12.3.1 Visualizing Word Frequencies with Pandas
No questions.
12.3.2 Visualizing Word Frequencies with Word Clouds
12.3 Q1: Which of the following statements a), b) or c) is false?
a. You can use the open source wordcloud module’s WordCloud class to generate
word clouds with just a few lines of code. By default, wordcloud creates rectan-
gular word clouds, but the library can create word clouds with arbitrary shapes.
b. To create a word cloud of a given shape, you can initialize a WordCloud object
with an image known as a mask. The WordCloud fills non-white areas of the mask
image with text.
c. The following code loads a mask image by using the imread function from the
imageio module that comes with Anaconda:
import imageio