Class: Mindee::Product::Custom::CustomV1Document
- Inherits:
-
Mindee::Parsing::Common::Prediction
- Object
- Mindee::Parsing::Common::Prediction
- Mindee::Product::Custom::CustomV1Document
- Defined in:
- lib/mindee/product/custom/custom_v1_document.rb
Overview
Custom Document V1 prediction
Direct Known Subclasses
Instance Attribute Summary collapse
-
#classifications ⇒ Hash<Symbol, Mindee::Parsing::Custom::ClassificationField>
readonly
All classifications in the document.
-
#fields ⇒ Hash<Symbol, Mindee::Parsing::Custom::ListField>
readonly
All value fields in the document.
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ CustomV1Document
constructor
A new instance of CustomV1Document.
- #to_s ⇒ String
Constructor Details
#initialize(prediction, page_id) ⇒ CustomV1Document
Returns a new instance of CustomV1Document.
19 20 21 22 23 24 25 26 27 |
# File 'lib/mindee/product/custom/custom_v1_document.rb', line 19 def initialize(prediction, page_id) super() @fields = {} @classifications = {} prediction.each do |field_name, field_prediction| field_sym = field_name.to_sym set_field(field_sym, field_prediction, page_id) end end |
Instance Attribute Details
#classifications ⇒ Hash<Symbol, Mindee::Parsing::Custom::ClassificationField> (readonly)
All classifications in the document
15 16 17 |
# File 'lib/mindee/product/custom/custom_v1_document.rb', line 15 def classifications @classifications end |
#fields ⇒ Hash<Symbol, Mindee::Parsing::Custom::ListField> (readonly)
All value fields in the document
12 13 14 |
# File 'lib/mindee/product/custom/custom_v1_document.rb', line 12 def fields @fields end |
Instance Method Details
#to_s ⇒ String
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mindee/product/custom/custom_v1_document.rb', line 30 def to_s out_str = String.new @classifications.each do |name, info| out_str << "\n:#{name}: #{info}".rstrip end @fields.each do |name, info| out_str << "\n:#{name}: #{info}".rstrip end out_str[1..].to_s end |