Skip to content

Instantly share code, notes, and snippets.

@geoffalday
Created November 1, 2011 14:09
Show Gist options
  • Save geoffalday/1330577 to your computer and use it in GitHub Desktop.
Save geoffalday/1330577 to your computer and use it in GitHub Desktop.
Ruby function for accessing the Viralheat sentiment API
require 'rubygems'
require 'sentiment_analysis'
def get_sentiment(text)
sa = SentimentAnalysis::Client.new(:api_key => 'YOUR_API_KEY')
sentiment = sa.review(:text => text, :format => :json)
# The limit on the text is 360 characters.
return sentiment
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment