Build a Twitter sentiment analysis application using Node.js modules
Articles,  Blog

Build a Twitter sentiment analysis application using Node.js modules

[ MUSIC ] RICH: Hi, this is Scott Rich from IBM. I’m going to give you a quick
introduction to this tutorial and tell you a bit of the story behind it. This is a good introduction to node.js
and some of the powerful applications that you can build really easily
using the modules that are out there. So the background behind this is that
a group of us were together in Austin for a design session last month,
and we were trying to think of a good application we could
use in our user scenario. We looked for something that
would be an interesting kind of system of engagement application. And someone else had a newspaper
in the conference room, and on the front page was a giant
PR debacle for a certain government, and we decided that they
might really be interested in building a sentiment analysis application
to see how people were reacting to this and what they were saying about the situation. It also seemed to be a good fit for this type of
application, since it was something that needed to be built quickly, since it wasn’t interesting
if it wasn’t available in a couple of days. It was something that could potentially process
a lot of data, and it was also something that might have an interest
in mobile application, since we we’re going be able
to track sentiment over time. So we decided to build the sentiment
analysis application using node.js, honestly without really knowing if
all the pieces existed to do that. Luckily I ran into Nick O’Leary from IBM
Emerging Technology in Hursley shortly after this, and he happened to be demonstrating
a sentiment analysis application built in node.js. So we had a quick talk, and he pointed me to
some of the building blocks that we needed, and now we had all the parts that we needed to
build this application that became the tutorial. So in the chart, we’re going to
use node.js, the Express framework, and a couple modules sentiment…for
sentiment analysis, and then Twitter for interfacing with Twitter. And with those we were able to put together
very quickly a pretty fun little sentiment analysis application. So, let me show you a little bit of the
code and demonstrate the application, and then we’ll let you get on to the tutorial. This “begin monitoring” function is really the
heart of our sentiment analysis application. You can see here with just a couple
lines of code we’ve connected to Twitter, the OAuth and verified our
credentials far easier than in lots of other languages or frameworks. With a few more lines of code, we open up a
stream at Twitter filtered for a certain phrase, and it says it’s going to send, you know, all
tweets matching that phrase to our listener. And then we set up within that listener on
the stream, we set it up so that every tweet that comes in is passed on to our
sentiment analysis application and analyzed, and then we add that to our score
to track the sentiment over time. So you can see really with just a
handful of lines of code we’ve been able to put together something really interesting
using these powerful node modules. So we can go to the entry field here,
enter a topic that we want to follow. So, we open a screen on Twitter and we’re
analyzing the tweets about Justin Bieber. And the Internet loves Justin
Bieber, not surprisingly. Let’s take a look at another topic. Pick a current event. Take a look at what’s happening about Syria. Looks like we caught one happy
tweet, which is surprising. Let’s see what else we see. Lots of activity around Syria. So I guess the Internet is
ambivalent on Syria this morning. Let’s try one more topic. Let’s take a look at the topic
that inspired this application. So, now we’re analyzing a different screen, looking at the content regarding
the NSA situation. And the Internet is not very happy about
what’s going on there, so there you go. Okay, so that’s the application, and hope
that you got a feel for what we’re able to do using these pieces, and I’ll
let you get on to the tutorial. Thanks. Bye.


Leave a Reply

Your email address will not be published. Required fields are marked *