A Python module to do a set of operations on tweets. It uses a collection of stopwords to train a dataset for the sentiment analysis. It uses the basic principle of bag-of-words used for natural language processing.
- numpy
- matplotlib(To plot sentiments)
from src import features, datalink, hashtags
import time
dblink = datalink.DatabaseConnectionDown('perilipsi_tweets')
emoTest = features.Emoticons()
dictTest = features.DictionaryTest()
hashtest = hashtags.hashtags()
testTweet, tweetTime = dblink.fetchTweet()['tweet'], dblink.fetchTweet()['time'] #You can pass anything you want
emo_test = emoTest.analyse(testTweet)
dict_test = dictTest.analyse(testTweet)
hash_test = hashtest.analyseHashtagTweet(testTweet)
print "Emoticons:", emo_test
print "DictionaryTest:", dict_test
print "Hashtags: ", hash_test
Output
Emoticons: {'positive': 0.33, 'negative': 0.66}
DictionaryTest: {'positive': 0.46153846153846156, 'negative': 0.5384615384615384}
Hashtags: {'positive': 0.38, 'negative': 0.62}
- Emoticons: This class uses emoticons detection to classify the passed string as positive or negative
- DictionaryTest: This class uses a set of English words and their subjectivity to give a score to a string
- hashtags: This class extracts hashtags from the string sent and calculates the sentiment based on a trained dataset
- AllCaps
- ElongatedWords
- Negation
- Punctuation
- Twitter Search API
- Facebook Graph API
Wolfram Alpha
Name | |
---|---|
Sudhanshu Mishra | [email protected] |
Ambar Mehrotra | [email protected] |