def sentimentanalysis(self, text_):
"""
Does sentiment analysis using SQLAlchemy API
"""
alchemyapi = AlchemyAPI()
# import ipdb; ipdb.set_trace()
if "" in text_.keys() and len(text_) < 2:
print "No tweets to analyse were found!!"
else:
response = alchemyapi.sentiment("text", text_)
sentrep = response["docSentiment"]["type"]
lst = [sentrep]
prettytable = PrettyTable(['Sentiment Type'])
t = prettytable.add_row(lst)
print prettytable
评论列表
文章目录