Blue Bird README
Blue Bird is a web interface for performing simple sentiment analysis of twitter. It follows Jeffrey Breen’s simple method of assigning each tweet a single integer representing each tweets sentiment based off the presence of positive and negative words. It then produces a stacked histogram of all the tweets for a given query.
Blue Bird’s sentiment analysis R code was originally written by Jeffrey Breen. The Apache licensed code is available here. The sentiment lexicon was originally compiled by Bing Liu and Minqing Hu and is available for download here. It is included in this repository by permission of the author.
Installation and Setup
- Clone this repository or click the download button in the upper right hand corner.
- Install all dependencies listed below.
- Open settings and set the host and port to the desired values.
- Run it the script as
./bluebirdit will start out as a background process.
- Enter a query and hit analyze. (There may be a long delay, the latency for fetching from twitter is very high)
Usage is relatively simple visit the webpage and enter a query then hit analyze and Blue Bird will search twitter, analyze the results and provide a stacked histogram of the results. Visit here (or read the source) to get a nice description of the method used to produce the charts before you start making conclusions. That’s all you need to know to get started.
- How do I make it display “Python” and “Ruby” when I search
Under show additional options there is a
Labelsoption, simply type a comma separated list in the same order as above and the labels will be used in place of the search. In this case “Python, Ruby”.
- How do I augment the word lists being used to judge the sentiment of
Under show additional options there is a positive and a negative words option. In their respective boxes, type a comma separated list of the words you’d like to augment the words list with and click analyze and you’ll get the results.
Adding Additional Services
By default, Blue Bird comes with one service, the tweepy interface to twitter. However, Blue Bird is written to allow the use of multiple services.
What is a service? As far as bluebird is concerned, a service as any python function that takes a single argument, the query, and returns an iterable of strings. Each string in the iterable is scored individually and the scores of all strings in the iterable are used to generate a histogram.
How do I write one? Open up
services.py and look at the tweepy
service for an example. The following is a skeleton for a service.
def myService(query): "My service, it's awesome!" # Magic happens: put your service code here return ["I'm happy, I wrote my first service", "I'm upset :(", query] # replace with any iterable of strings (iterables # include lists, tuples and more)
Once you’ve written you’re service, go to the bottom of
and add it to the SERVICES variable:
SERVICES = [("Tweepy", getTweetsText), ("My Service", myService)]
Now restart Blue Bird and your service should be available.
Python (tested in 2.7)
Can be installed with “easy-install name”
R (tested with 2.13.1)
Can be install in R with “install.packages(‘name’)”
- If you get the following import error:
ImportError: libR.so: cannot open shared object file: No such file or directory
Then you must add the following to your .bashrc
/usr/lib/R/lib may be a different path depending on your R install. It should be replaced with the directory that contains:
- Bug when nothing returned in search. Defaults to one neutral item in the histogram to prevent R from raising an error.