In this chapter we will see how to perform sentiment analysis over Twitter data. Initially, we introduce the Twitter API with Python. Then, we distinguish the basic elements of a sentiment classification. Finally, we present the Natural Language Toolkit (NLTK) to implement the tweets' sentiment analyzer.
In this chapter we will cover:
The anatomy of Twitter data
Using OAuth to access Twitter API
Getting started with Twython:
Working with timelines
Working with followers
Working with places and trends
Effective norms for English words
Get started with Natural Language Toolkit (NLTK)
Bag of words
Sentiment analysis of tweets
In Chapter 4, Text Classification, we presented a basic introduction to text classification. In this chapter, we will perform a sentiment analysis of tweets to rate the emotional value (positive or negative) using classification with Naive Bayes method.