Created
August 9, 2018 06:16
-
-
Save peckjon/755077b1de4450612745c1d398594b9d to your computer and use it in GitHub Desktop.
Introduction to Twitter Topic and Sentiment Analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Algorithmia | |
input = { | |
"query": "seattle seahawks", | |
"numTweets": "1000", | |
"auth": { | |
"app_key": "YOUR_TWITTER_APP_KEY", | |
"app_secret": "YOUR_TWITTER_APP_SECRET", | |
"oauth_token": "YOUR_TWITTER_OAUTH_TOKEN", | |
"oauth_token_secret": "YOUR_TWITTER_OAUTH_TOKEN_SECRET" | |
} | |
} | |
client = Algorithmia.client('YOUR API KEY') | |
algo = client.algo('nlp/AnalyzeTweets/0.1.9') | |
print algo.pipe(input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
allTweets: [{ | |
created_at: 'Mon Jan 16 21:20:49 +0000 2017', | |
negative_sentiment: 0, | |
neutral_sentiment: 0.5670000000000002, | |
overall_sentiment: 0.8550000000000002, | |
positive_sentiment: 0.4330000000000001, | |
text: 'RT @NFL: Beautiful toss, Matty Ice!\nBeautiful catch, Mo Sanu!\n\n#SEAvsATL #NFLPlayoffs\n\n https://t.co/albHUG1oll', | |
tweet_url: 'https://twitter.com/statuses/821104945655115778' | |
} { ... | |
}], | |
negLDA: [{ | |
falcons: 2, | |
future: 2, | |
line: 1, | |
loss: 1, | |
money: 1, | |
offensive: 1, | |
savings: 1, | |
seahawks: 2 | |
}, | |
{ ... | |
} | |
], | |
negTweets: [{ | |
created_at: 'Mon Jan 16 21:12:16 +0000 2017', | |
negative_sentiment: 0.3520000000000001, | |
neutral_sentiment: 0.6480000000000002, | |
overall_sentiment: -0.7654, | |
positive_sentiment: 0, | |
text: 'Seahawks future will not look good if our management has another offseason of signing no offensive line', | |
tweet_url: 'https://twitter.com/statuses/821102796514570240' | |
}, | |
{ ... | |
} | |
], | |
posLDA: [{ | |
atlanta: 1, | |
beat: 1, | |
beating: 1, | |
congratulations: 1, | |
falcons: 1, | |
seahawks: 2, | |
seattle: 2, | |
significant: 1 | |
}, { ... | |
}], | |
posTweets: [{ | |
created_at: 'Mon Jan 16 21:29:36 +0000 2017', | |
negative_sentiment: 0.129, | |
neutral_sentiment: 0.6900000000000002, | |
overall_sentiment: 0.2942, | |
positive_sentiment: 0.181, | |
text: 'Congratulations to the Atlanta Falcons for beating Seattle Seahawks! Keep it up and beat the Packers this... https://t.co/119WQSbKoz', | |
tweet_url: 'https://twitter.com/statuses/821107158892904449' | |
}, { ... | |
}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment