Skip to content

Instantly share code, notes, and snippets.

@peckjon peckjon/input.json
Created Aug 9, 2018

Embed
What would you like to do?
Introduction to Twitter Topic and Sentiment Analysis
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)
{
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
You can’t perform that action at this time.