def get_toot_sentiment(toot):
'''
Utility function to classify sentiment of passed toots
using textblob's sentiment method
'''
# create TextBlob object of passed toot text
analysis = TextBlob(toot)
# set sentiment
if analysis.sentiment.polarity > 0:
return 'positive'
elif analysis.sentiment.polarity == 0:
return 'neutral'
else:
return 'negative'
评论列表
文章目录