Real-time sentiment analysis in Python using twitter's streaming api
Added
TweetData.fetchbin
.
empty
allows you to enable returning empty bins.TweetBin
instead of a tuple.TweetFeels.sentiments
generator.
nans
allows you to enable a nan sentiment value to be returned when data is missing.Sentiment
object.The following features were added:
pos
, neu
, and neg
dimensions added to tweet dataThis release changes the format of the sqlite3 database which keeps the history of all tweets. As a result, you will need to convert any databases that were created with the 0.1 version. This can be done like so:
from tweetfeels import TweetData, Tweet
import time
def to_dict(row):
ts = time.strftime('%a %b %d %H:%M:%S +0000 %Y', row.created_at.to_pydatetime().timetuple())
return {
'id_str': row.id_str, 'created_at':ts, 'text':row.text,
'favorite_count':str(row.favorite_count), 'favorited':str(row.favorited),
'lang':'en', 'retweet_count':str(row.retweet_count), 'source':row.source,
'user':{'friends_count':str(row.friends_count), 'followers_count':str(row.followers_count),
'location':row.location}
}
if __name__ == "__main__":
old_db = TweetData('feels-0.1.sqlite')
new_db = TweetData('feels-0.2.sqlite')
for df in old_db.all:
for row in df.itertuples():
t = Tweet(to_dict(row))
new_db.insert_tweet(t)
Update the filenames for the old_db
and new_db
accordingly.