In an age where more and more data is generated, and especially where every individual can post his or her opinion on the internet, the value of automatically analyzing these posts with high accuracy on a large scale is important for businesses and politics. In Chapter 4, Recurrent and Recursive Neural Networks, we've already shown how to apply RNNs with LSTM units to classify short sentences, such as movie reviews. In the following recipe, we will increase the complexity by classifying the sentiments of Twitter messages. We do this by predicting both binary classes and fine-grained classes.
Analyzing sentiment
How to do it...
- We start by importing all the libraries as follows:
from nltk.tokenize import word_tokenize...