Class: Mindee::Product::Universal::UniversalDocument
- Inherits:
-
UniversalPrediction
- Object
- Mindee::Parsing::Common::Prediction
- UniversalPrediction
- Mindee::Product::Universal::UniversalDocument
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/universal/universal_document.rb
Overview
Universal Document V1 prediction
Instance Attribute Summary
Attributes inherited from UniversalPrediction
Instance Method Summary collapse
-
#initialize(raw_prediction) ⇒ UniversalDocument
constructor
A new instance of UniversalDocument.
Methods inherited from UniversalPrediction
Methods included from Mindee::Parsing::Universal
Methods inherited from Mindee::Parsing::Common::Prediction
Constructor Details
#initialize(raw_prediction) ⇒ UniversalDocument
Returns a new instance of UniversalDocument.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mindee/product/universal/universal_document.rb', line 13 def initialize(raw_prediction) super raw_prediction.each do |field_name, field_contents| if field_contents.is_a?(Array) @fields[field_name] = Parsing::Universal::UniversalListField.new(field_contents) elsif field_contents.is_a?(Hash) && Parsing::Universal.universal_object?(field_contents) @fields[field_name] = Parsing::Universal::UniversalObjectField.new(field_contents) else field_contents_str = field_contents.dup if field_contents_str.key?('value') && field_contents_str['value'].nil? == false field_contents_str['value'] = field_contents_str['value'].to_s end @fields[field_name] = Mindee::Parsing::Standard::StringField.new(field_contents_str) end end end |