Twitter Faces is a real-time data visualization of agregated people mood in cities around the world. Every two minutes, the application gets the latest one hundred tweets
around a city and does a basic sentimental analysis. Then an average mood is calculated, based on the number of positive and negative people comments, and visualized as a smiling or a sad face.
For the sentiment analysis, I have decided to use the most basic algorithm. I would scan every tweet and count every positive or negative word, found in a word list. The average mood is calculated like this: MOOD = POSITIVE WORD COUNT – NEGATIVE WORD COUNT, if the MOOD is equal to zero, the tweet is marked as neutral, if the MOOD is higher then 0, the tweet is marked as positive and if MOOD is lower then 0, as negative.
I have looked into using Sentiment analysis sites, like http://sentiment140.com, but most of them were paid services and querying an additional API would slow things down, so for this project I decided to go with something free and fast.
The server side script, runs on (you guessed it) the server :) It’s implemented with Node.js, using Socket.IO and Twit modules. Every two minutes the script will download the last 100 tweets from four cities (London, Cape Town, New York, Sydney – all English speaking), then it will do a sentiment analysis and save the aggregated results as an array. On the other side, it will listen for client connections and will respond to all requests for data.
The client runs in the user’s browser and the application could be loaded in almost every major browser version. When loaded the application connects to the server and request all aggregated city data. Then from the average sentiment data, it will generate a face expressing the mood of the people tweeting around the city. The application runs in real time, so all face changes, on new data, are animated. I really wanted to make the face looks more lively, so I have implemented some animations, like rolling and closing eyes, running all the time.