Application
We will now create a pipeline that takes a tweet and determines whether it is relevant or not, based only on the content of that tweet.
To perform the word extraction, we will be using the NLTK, a library that contains a large number of tools for performing analysis on natural language. We will use NLTK in future chapters as well.
Note
To get NLTK on your computer, use pip
to install the package: pip3 install nltk
If that doesn't work, see the NLTK installation instructions at www.nltk.org/install.html.
We are going to create a pipeline to extract the word features and classify the tweets using Naive Bayes. Our pipeline has the following steps:
- Transform the original text documents into a dictionary of counts using NLTK's
word_tokenize ...
Get Python: Real-World Data Science 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.