NLP in Python
#importing tweeter library and textblob
import tweepy
from textblob import TextBlob
#making connection with twitter
consumer_key='vBsuS1MZU1HZkcEZCF1X3RcN1'
consumer_secret='BlK6sqtAxPrDWcohheZ3WleCsdzV68oilt6sHM122FfrU5gDj9'
access_token='2840514410-tvwxQYYIk3WBBpALt2EnPJiSiro6oQjEk6HHPrt'
access_token_secret='AdgQONrI4VpM88g6g2AZvlVAlGNwteSOYh0lBZ6Q8rd45'
auth=tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api=tweepy.API(auth)
public_tweets=api.search('Trump')
text_list=[]
sentiment_list=[]
for tweet in public_tweets:
text_list.append(tweet.text)
print(tweet.text)
analysis=TextBlob(tweet.text)
print(analysis.sentiment)
sentiment_list.append(analysis.sentiment)
No comments:
Post a Comment