Class: SyllabsApi::Modules::NamedEntityExtraction::Response
- Inherits:
-
Object
- Object
- SyllabsApi::Modules::NamedEntityExtraction::Response
- Defined in:
- lib/syllabs-api/modules/named_entity_extraction/response.rb
Instance Attribute Summary collapse
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
Instance Method Summary collapse
-
#initialize(json) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(json) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/syllabs-api/modules/named_entity_extraction/response.rb', line 9 def initialize(json) @entities = [] ENTITY_TYPES.each do |raw_entity_type| raw_entities = json['response']['entities'][raw_entity_type] next if raw_entities.nil? raw_entities.each do |raw_entity| # puts "[#{raw_entity_type}] #{raw_entity['text']}: #{raw_entity['count']}" @entities << Entity.new(raw_entity_type, raw_entity['text'], raw_entity['count']) end end rescue Exception => e raise e end |
Instance Attribute Details
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
7 8 9 |
# File 'lib/syllabs-api/modules/named_entity_extraction/response.rb', line 7 def entities @entities end |