Skip to content
Viralheat Sentiment Analysis Gem
Ruby
Latest commit 07df253 Sep 13, 2011 Raj Kadam Bump 0.0.2
Failed to load latest commit information.
doc
lib Bump 0.0.2 Sep 13, 2011
spec
.gitignore for development, your personal api key must be stored in spec/config.yml Sep 13, 2011
Gemfile fix : require the proper version of rspec Sep 14, 2011
Gemfile.lock fix : require the proper version of rspec Sep 13, 2011
Rakefile beef up Rakefile tasks set Sep 13, 2011
Readme.markdown
sentiment_analysis.gemspec install and use 'vcr' to test quota() with real data Sep 13, 2011

Readme.markdown

The Sentiment Analysis Ruby Gem

A Ruby wrapper for the Viralheat Sentiment Analysis API

see : http://viralheat.com/developer/sentiment_api

Installation

gem install sentiment_analysis

Getting an API Key

You can get an API key by visiting http://www.viralheat.com/developer. Sign up as a FREE developer and get a key for use with this gem. The developer dashboard will also show you details on your quota.

How to use

Simple way

require 'sentiment_analysis'
sa = SentimentAnalysis::Client.new(:api_key => '0123456789')

puts sa.quota
  # => 5000

puts as.review("i don't like this")
  # => {"prob":0.732603741199471,"mood":"negative","text":"i don't like this"}

puts as.train(:text => "I don't like coffee'",:mood => 'negative')
  # => {"status":"ok"}

Choose the format - :json

puts sa.quota(:format => :json)
  # => {"quota_remaining":5000}

Choose the format - :xml

puts sa.quota(:format => :xml)
  # => <?xml version="1.0" encoding="UTF-8"?>
       <result>
         <quota_remaining>4976</quota_remaining>
       </result>

puts as.review("i don't like this", :format => :xml)
  # => <?xml version="1.0" encoding="UTF-8"?>
       <result>
         <text>I don't like coffee</text>
         <mood>negative</mood>
         <prob>0.55865964876338</prob>
       </result>

puts as.train(:text => "I don't like coffee'",:mood => 'negative', :format => :xml)
  # => <?xml version="1.0" encoding="UTF-8"?>
       <result>
         <status>ok</status>
       </result>
Something went wrong with that request. Please try again.