~Kamen

17 Feb 2013

Screen Shot 2013-02-17 at 9.03.37 PM

Description

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.

Implementation

diagram

The application is divided in two, a server and a client. The server is implemented, using server side JavaScript with Node.JS and the client, uses Processing’s little brother – Processing.js, so the visualization could be loaded on every major browser, without the need for additional plug-ins, like Java or Flash. Procesing.js is also supported on almost every modern mobile browser, but for now it runs rather slow, so for a better support on mobile, I will need to use something different, like CSS3 transforms and animations, or an SVG framework like Raphael.JS.

Sentiment Analysis

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.

Server Side

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.

Client Side

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.

Source Code: Github
Demo: http://www.kamend.com/demos/twitterfaces/