Project 4: Twitter Sentiment Analysis (code available on Github)
Scope: Build a Node.js project that uses the twit and sentiment modules to perform sentiment analysis on a set of tweets containing a given piece of text.
A few notes on the sentiment module (quoting from its github page): it is “a Node.js module that uses the AFINN-111 wordlist to perform sentiment analysis on arbitrary blocks of input text.” The AFINN-111 wordlist, in turn, is “a list of English words rated for valence with an integer between minus five (negative) and plus five (positive).”
Basically, the module takes this library of (currently) 2477 words with their associated scores, and uses that to measure the positivity or negativity of a given piece of text. It doesn’t detect language or context. Therefore, it has somewhat limited value, especially when working with such short snippets of text as tweets.
What I Learned:
- Node.js and Express: My first Node.js and Express project.
- Using the Twitter Search API.
- Heroku: This is the first time I’ve deployed anything to Heroku, and it was a delightfully quick and easy process.
What I Left:
- This is, simply put, not an enormously useful app. The sentiment module isn’t very sophisticated, as discussed above, and even its limited powers are largely wasted on such short snippets of text as tweets. Perhaps I might have been able to finesse it, but it was more an exercise in using several new technologies than in providing a properly useful sentiment analysis tool for Twitter.
- It probably would have been more useful to use, say, the Twitter Streaming API and pull in a steady stream of tweets over the course of a day, rather than do a simple search for a small number of tweets. I may have a look at the streaming API at some future date.