Skip to content

SdAswin/SD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

SD

#Sentiment Analysis on Twitter Data #Use the tweepy library to fetch tweets and nltk for sentiment analysis..

import tweepy from textblob import TextBlob

Twitter API credentials

consumer_key = 'YOUR_CONSUMER_KEY' consumer_secret = 'YOUR_CONSUMER_SECRET' access_token = 'YOUR_ACCESS_TOKEN' access_token_secret = 'YOUR_ACCESS_TOKEN_SECRET'

Authenticate to Twitter

auth = tweepy.OAuth1UserHandler(consumer_key, consumer_secret, access_token, access_token_secret) api = tweepy.API(auth)

Fetch tweets

public_tweets = api.home_timeline(count=10) for tweet in public_tweets: analysis = TextBlob(tweet.text) print(f"Tweet: {tweet.text}") print(f"Sentiment: {analysis.sentiment}\n")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published