Class: SyllabsApi::Modules::Terms::Base
- Inherits:
-
Object
- Object
- SyllabsApi::Modules::Terms::Base
- Defined in:
- lib/syllabs-api/modules/terms/base.rb
Constant Summary collapse
- API_URL =
'http://api.syllabs.com/v0/terms'
- RESPONSE_FORMAT =
'json'
- LEMMATIZE =
true
- CONFIDENCE =
0.3
- LANG =
'detect'
Class Method Summary collapse
- .fetch_response(body) ⇒ Object
- .process(api_key, text, lemmatize = LEMMATIZE, confidence = CONFIDENCE, lang = LANG) ⇒ Object
Class Method Details
.fetch_response(body) ⇒ Object
24 25 26 27 28 |
# File 'lib/syllabs-api/modules/terms/base.rb', line 24 def self.fetch_response(body) Terms::Response.new JSON.parse(body) rescue Exception => e raise e end |
.process(api_key, text, lemmatize = LEMMATIZE, confidence = CONFIDENCE, lang = LANG) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/syllabs-api/modules/terms/base.rb', line 13 def self.process(api_key, text, lemmatize=LEMMATIZE, confidence=CONFIDENCE, lang=LANG) params = {text: text, format: RESPONSE_FORMAT, lemmatize: lemmatize, confidence: confidence, lang: lang} http_response = HttpProcessor.post(api_key, API_URL, params) fetch_response(http_response.body) rescue Exception => e raise e end |