Skip to content

Instantly share code, notes, and snippets.

@dannyvassallo
Created April 16, 2015 18:56
Show Gist options
  • Save dannyvassallo/88ebb4152e5faff07c82 to your computer and use it in GitHub Desktop.
Save dannyvassallo/88ebb4152e5faff07c82 to your computer and use it in GitHub Desktop.
Twitter Sentiment Report RUBY
require 'sad_panda'
require 'twitter'
config = {
consumer_key: "*",
consumer_secret: "*",
}
client = Twitter::REST::Client.new(config)
client.search("to:MDBlockParty", result_type: "recent").take(200).each do |tweet|
the_tweet = tweet.text.gsub /[\x00\/\\:\*\?\"<>\|]/, ''
puts "================================"
puts "User = #{tweet.user.screen_name}"
puts "Tweet = #{tweet.text}"
puts "Emotion = " + SadPanda.emotion(the_tweet)
puts "Polarity = " + SadPanda.polarity(the_tweet).to_s
puts "================================"
puts " "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment