Class: Repustate
- Inherits:
-
Object
- Object
- Repustate
- Defined in:
- lib/repustate.rb
Instance Method Summary collapse
-
#bulk_sentiment(options = {:items => [], :lang => 'en'}) ⇒ Object
Bulk score multiple pieces of text (not urls!).
-
#clean_html(options = {:url => nil}) ⇒ Object
Clean up a web page.
- #entities(options = {:text => nil, :lang => 'en'}) ⇒ Object
-
#initialize(key, version = 'v3') ⇒ Repustate
constructor
A new instance of Repustate.
-
#sentiment(options = {:text => nil, :lang => 'en'}) ⇒ Object
Retrieve the sentiment for a single URl or block of text.
- #topic(options = {:text => nil, :topics => nil, :lang => 'en'}) ⇒ Object
Constructor Details
#initialize(key, version = 'v3') ⇒ Repustate
Returns a new instance of Repustate.
23 24 25 26 |
# File 'lib/repustate.rb', line 23 def initialize(key, version='v3') @key = key @version = version end |
Instance Method Details
#bulk_sentiment(options = {:items => [], :lang => 'en'}) ⇒ Object
Bulk score multiple pieces of text (not urls!).
35 36 37 38 39 40 |
# File 'lib/repustate.rb', line 35 def bulk_sentiment(={:items => [], :lang => 'en'}) items_to_score = Hash[[:items].enum_for(:each_with_index).collect { |val, i| ["text#{i}", val] }] call_api('bulk-score', items_to_score) end |
#clean_html(options = {:url => nil}) ⇒ Object
Clean up a web page. It doesn’t work well on home pages - it’s designed for content pages.
44 45 46 47 |
# File 'lib/repustate.rb', line 44 def clean_html(={:url => nil}) use_http_get = true call_api('clean-html', , use_http_get) end |
#entities(options = {:text => nil, :lang => 'en'}) ⇒ Object
49 50 51 52 |
# File 'lib/repustate.rb', line 49 def entities(={:text => nil, :lang => 'en'}) use_http_get = true call_api('entities', ) end |
#sentiment(options = {:text => nil, :lang => 'en'}) ⇒ Object
Retrieve the sentiment for a single URl or block of text. Optionally select a language other than English.
30 31 32 |
# File 'lib/repustate.rb', line 30 def sentiment(={:text => nil, :lang => 'en'}) call_api('score', ) end |
#topic(options = {:text => nil, :topics => nil, :lang => 'en'}) ⇒ Object
54 55 56 57 |
# File 'lib/repustate.rb', line 54 def topic(={:text => nil, :topics => nil, :lang => 'en'}) use_http_get = true call_api('entities', ) end |