Created
November 1, 2011 14:09
-
-
Save geoffalday/1330577 to your computer and use it in GitHub Desktop.
Ruby function for accessing the Viralheat sentiment API
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
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