Thursday, December 16, 2010

Twitter Sentiment Analysis

So I have started gaining some interest in Social Analytics and NLP. One of the major questions that social analytics answers is How are my product(s)/Company performing or percieved among end users. This brings us to Sentiment Analysis which means determining the tone of the user i.e. whether he is accolading or bitching. Twitter arguably is the biggest platform where most of the users express their opinions about a certain company/product/service etc. What follows below is a quick and dirty way to analyse sentiment (tone) of tweets for any specific term.

1. I love python. If you don't have it, get it. Its awesomely easy to learn.

2. Get twitter data. I've used the normal search and some BeautifulSoup parsing. Better way will be to use API with OAuth.
import urllib,urllib2,BeautifulSoup
from BeautifulSoup import BeautifulSoup
from HTMLParser import HTMLParser
import time
class MLStripper(HTMLParser): 
    def __init__(self): 
        self.reset() 
        self.fed = [] 
    def handle_data(self, d): 
        self.fed.append(d) 
    def get_data(self): 
        return ''.join(self.fed)

q="iphone"  
html=urllib.urlopen("http://search.twitter.com/search?q="+q).read()
soup=BeautifulSoup(html)
text_file=open("tw_"+q+"_"+str(time.time())+".txt", "w")
for msg in soup.findAll("span",{"class":"msgtxt en"}):
 s=MLStripper()
 s.feed(str(msg))
 text_file.write(s.get_data()+"\r\n\r\n") 
text_file.close()

3. Open the above file and mark each tweet as good (Y) or bad (N) manually based on the content. The more data you mark, the better will be the accuracy of the model which will be trained in next step.
Iphone is awesome,Y
Iphone sucks, big time for me,N
Just bought Iphone 4, its feels really nice resting in my bare hands,Y

4. Download and install NLTK python package. Train the Naive Bayes classifier model with the tweets you just marked in above step.
import nltk.classify.util
from nltk.classify import NaiveBayesClassifier
def word_feats(words):
 return dict([(word,True) for word in words]) 
f=open("tw_iphone_23423423.txt")
trainfeats=[]
while True:
 line=f.readline()
 print line[:len(line)-3]
 print line[len(line)-2:]
 trainfeats.append((word_feats(line[:len(line)-3].split(' ')),line[len(line)-2:len(line)-1]))
 if not line:
  break  
classifier=NaiveBayesClassifier.train(trainfeats)

5. We are done. Test the model on any random text/tweet.
>>> classifier.classify(word_feat("I like my iphone. It's awesome"))
'Y'

Sunday, January 10, 2010

Polar clock gadget fo windows 7

PixelBreaker has an amazing polar clock. My first thought: that could look uber-cool on my win 7 desktop as a gadget. There was none available on the internets though. So, here’s the one that I put together : PolarClock.gadget . A quirk: an error box on initial launch, just click “dismiss all” and you are set

Friday, May 15, 2009

Hello world again

Hello world,

How are you doing these dayz ? This is one of my favorite zunk posts. Do you like it ? No Yes ? If you don't, good... you are normal. Go outside, do bird watching, life is beautiful. If you reading this blog, you are missing life. Yes you are.

Monday, February 2, 2009

rogue dance .... he he

Posted by Picasa

Sunday, January 11, 2009

iMac geeks

Wednesday, January 7, 2009

applying thought

scratching my head

Posted via Pixelpipe.

Thursday, January 1, 2009

arunachal.prashant2228.com

Those of you who know me personally might also be knowing that I grew up in Arunachal Pradesh and am very passionate about it. Internet penetration is very very shallow in this eastern himalayan region, making it an ultra-slow news region.

It would be nice if all the news or blogs related to arunachal pradesh becomes accessible from single webpage.

Enter http://arunachal.prashant2228.com . Created using a combination of yahoo pipes and google appengine. Here, you can view the news, blogs, images & videos in reverse chronological order.

Wednesday, December 31, 2008

Things I'm doing with my Iphone

Its been just 3 days since iPocketed the iphone, still iAm in a postition to prepare a list of things iDo with it. To widen the capabilities iInstalled wifi at home as India do not have a 3G (or any high speed mobile internet) connection.

1. First and foremost is fun with people. Blaming on the steep price(around $700), very few people in india own iphone, none in my 30 people team at office. Fun were the moments when I demoed them how to control a drunkard, how easy it is to drive, how to smoke in a smoke free zone... and of course.... how to regain the lost art of flute playing.

2. Controlling my windows xp computer, playing with the new remote control for pc.

3. Watching youtube , posting twits, checking friendfeed, searching interwebz through voice, converting noice into music, emails.... and of course traditional internet browsing.

4. Playing n++ number of games.


I was rich, but now have to make my piece with sukhi roti and dal. Looking for some free eatable app at appstore .....

Saturday, December 20, 2008

Some great food @Metro@Bangalore

Mostly so because didn't had good Momos in a long time, and just got an opportunity to gobble up as much as I can. Going with the name, ambience was set like some metro train with waiters in smarty caps.
Buffet Items @300 INR:
Chickens 3-4 dishes
Soups, Momos, Chats , Salads...
All regulars (rice , naans, biryani etc..)
Desserts (pastries, rasgulla, truffles etc..)
Veg Items ( din't even looked at :D)
Liquors (costs extra)

Location: 3rd Floor, Total Mall, Madiwala, Bangalore

Saturday, September 27, 2008

ChucK - Audio Programmming

Found an easy way to create music - ChucK. It's an Strongly-timed, Concurrent, and On-the-fly audio programming language.

Now this might be able to help me out in creating some sensical music. I'd never been able to handle any musical instruments, ahh well except that bamboo flute that I used to rock up well.

Saturday, September 20, 2008

Arguments ??

Arguments do not exist. This statement is valid only if you consider it "as is" - an universal truth. You cannot ask "why" or "how" for there would be no *argument(s)* to support it. Not at all. Because you can answer to "why" or "how" only through arguments and if arguments do not exist your every *argument* is just some sound waves or some strange combination of alphabetical diagrams.

Tuesday, September 2, 2008

Google Chrome

Got all excited when saw the url http://google.com/chrome becoming active, and within nano-seconds clicked the download. I've been watching this url whole day since the announcement that Chrome is gonna released today.

Downloaded the installer and ran it, seems its downloading the real stuff now. The first installer was just a hook to download the real file.

OK. Download is done. Now installing ...

Installation done ! Lets click the magic "Start Google Chrome" button now. Oops... it wants my firefox to close so that it can import settings. Lets do it.

Oh myyyyyyyyyy... It such a nifty-kitty cute thing. I am now typing this blog post in CHROME.

Testing.....
1. Incognito: niceee 
2. OmniBar: Searches not only history and bookmarks, but also the web.
3. Developer: Out of the box javascript debugging and a firebug like tool.
4. Task Manager with special "Stats for nerds" option. Google really does care about u.
5. Great job creating shortcuts for websites.
6. Can't see the search bar.

Overall rating 8/10. Awesome design. The slick look gives an appearacne of a faster and light-weight tool. 

However, with ubiquity around I'm not sure about switching. But hell ya... I will go all CHROMEeee for whole this week.

Saturday, May 24, 2008

Snaps from London Trip

Friday, April 25, 2008

Its 4:25 am

And I feel like writing something. Today I will discuss on whether it is possible to write without using your mind. To start with, as soon as I decided that I will write my mind starts running searching for topic. Then I say whats the need of topic, just write anything. Ok then I start writing anything. No need to care about topic, no need to care about if somebody will ever read this post. If there is no need to care about anything, then why am I still thinking.

Ok..... so finally I came to the conclusion that I should stop writing here now until it gets dead bore. Huh... but I will write.

baby baby... mama mama.... yes papa... la aall sosdopa lasdifjakdl ldsoadsijfakdf..... jowhsdjnfwiiujefhkjsf

fdkjfaskdhfuiwe,f..adsfsfd sdfsdfasdfjoijewjhpsodflejiosfsfanpwoejfw...... sljfow...sajfieij-39 fsdkfs;aa..... wow am really a good writer.

Wednesday, April 16, 2008

FriendFeed

A few days back finally joined FriendFeed after I could not contain anymore the rave reviews of it on blogosphere. Well, initially had only one friend , Scoble. And the updates from this single blogger were really HUGE, though most of them were just twits.

Today thought of importing my real life friends and therefore added there emails. As expected I got only 3 names that were already on FriendFeed, and even to them never met personally. It sometimes kills to have such a non-techy(aka *idiots*) friend circle. But I love to see the updates of real life Friends. I really got excited when Orkut(a big social thing in India) included "updates from friends" feature, it really is a great way to know that your friends are alive and active. 100s of updates from Scoble doesn't really give 10% of joy that I get when seeing the updates from my *real life* friends. Though the updates from Scoble are far more beneficial for me.

Lets see how many of my guys join this through my automated email to them. Here's to hoping getting my friends on FriendFeed.

Just in case anybody wants to follow me : http://friendfeed.com/prashant2228.

Sunday, April 13, 2008

Prashant2228

So, this is a weird name *Prashant2228*. Well it is. It kind of started when there were days I clicked on "Check Availability" every 5th time to get a username that was available. I felt a need to come up with something really unique. But apparently I didn't gave it much time as its obvious that I did found something unique but forgot the coolness factor. Just got my name appended with my college scholar number. Ever since than never really got an opportunity to ponder over unique names to match the availability.

And today removed the last stumbling block by registering prashant2228.com, well you know just in case I get famous and before someone tries to register it. Also added Google Apps to it.

And also started a blog at Bloggers with the obvious name prashant2228.blogspot.com. Though I had a blog by that name earlier where I used to write some techno stuff, I got it renamed to prashant2228-old.blogspot.com. I did posted very regularly and religiously on that blog but lost interest after few months. And fairly enough its quite possible that I may loose interest this time as well. Well, we will see.

Wednesday, January 10, 2007

I am back

This blog went on a break at the yearend. I took a break from writing logs in order to celebrate something called life before I could get up used by by it. I realized I was turning more like a bot -- searching for content over the net and bragging about it all for nothing but getting some Google money.

So hereinafter, no google ads, no reproduction of news, only pure opinions and therefore setting up the highest frequency of postings record is not my aim. Or rather I should say "Mere eXperiences".

Thursday, December 28, 2006

10x10 -- Thats 100


TenByTen has been around now for more than two years. When it was released two years back there were not many professionals to give it a good competition, Digg was still in inception and Slashdot was not much known. In what followed in the next two years, zillions of news services surfaced, and TenByTen got lost somewhere in the ocean. Had it not accidently been rediscovered today it would have converted to fossils after remaining years inside the ocean.


Even after two years with so many news services around the interface still looked sleek and browsing through the flash based interface looked painless. The greatest drawback is that it draws news from only three sources (Reuters, BBC and NYT) nevertheless it is still worth giving a try. You can browse through the news of every month,day and hour starting 2004. The site more looks like kinda demo how a news service works.


Wednesday, December 27, 2006

TailRank Tale

Tailrank is a news aggregator which has been around for a little now. The service marks the quality of a news story by the number of times the story has been blogged or linked. The stories are aggregated from various sources much like Digg. But unlike Digg which sometimes suffer from worthless Diggs, the Tailrank system looks more robust as someone will take the pain of blogging or linking something only when its worthwhile. And with the rise of bloggers at exponential rate in every field its obvious that a good story will receive a lot of links.

Features that can make a difference

1. Recently added video category populated with videos from various video sharing services (mostly youtubes) which are selected on the basis of number of links or embeds. (TailRank Video)

2. Providing deep tracking for a story with the "track this thread", to get depth and breadth of a story.

3. Easy access to news by date. For 21st dec news -- "http://tailrank.com/2006-12-21".

4. Import service from other aggregators (bloglines, newsgator). Manual uploading of OPML files. (Tailrank import)

5. Allowing for embedding Tailrank on your blog with fully customizable CSS.

Tuesday, December 26, 2006

Geek Guns

Here is a compilation of high-tech electronically controlled guns with video demos of all in action. In case you are interested in discovering guns right there in your office see previous post "Discover Guns in Your Office".