Class: TermExtractor::Yahoo
- Inherits:
-
Object
- Object
- TermExtractor::Yahoo
- Defined in:
- lib/term_extractor/parsers/yahoo.rb
Overview
Interface to the Yahoo Term Extractor API.
Constant Summary collapse
- HOST =
"search.yahooapis.com"
- PATH =
"/ContentAnalysisService/V1/termExtraction"
Instance Method Summary collapse
-
#get_terms(content, query = nil) ⇒ Object
Extracts terms from content provided.
-
#initialize(api_key) ⇒ Yahoo
constructor
Create a new Yahoo Term Extractor instance.
Constructor Details
#initialize(api_key) ⇒ Yahoo
Create a new Yahoo Term Extractor instance. A valid API key must be provided.
16 17 18 |
# File 'lib/term_extractor/parsers/yahoo.rb', line 16 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#get_terms(content, query = nil) ⇒ Object
Extracts terms from content provided. Provide an optional query to provide context for your terms.
22 23 24 25 26 |
# File 'lib/term_extractor/parsers/yahoo.rb', line 22 def get_terms(content, query = nil) response = Net::HTTP.post_form(uri, query_hash(content, query)) raise RemoteServerError unless response.code == "200" terms = parse_for_terms(response.body) end |