Class: SyllabsApi::Modules::NamedEntityExtraction::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/syllabs-api/modules/named_entity_extraction/base.rb

Constant Summary collapse

API_URL =
'http://api.syllabs.com/v0/entities'
RESPONSE_FORMAT =
'json'

Class Method Summary collapse

Class Method Details

.fetch_response(body) ⇒ Object



25
26
27
28
29
# File 'lib/syllabs-api/modules/named_entity_extraction/base.rb', line 25

def self.fetch_response(body)
  NamedEntityExtraction::Response.new JSON.parse(body)
rescue Exception => e
  raise e
end

.process(api_key, text) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/syllabs-api/modules/named_entity_extraction/base.rb', line 16

def self.process(api_key, text)
  params = {text: text, format: RESPONSE_FORMAT}
  http_response = HttpProcessor.post(api_key, API_URL, params)
  fetch_response(http_response.body)
rescue Exception => e
  raise e
end