Class: Mindee::V1::Parsing::Common::Extras::Extras
- Inherits:
-
Object
- Object
- Mindee::V1::Parsing::Common::Extras::Extras
- Defined in:
- lib/mindee/v1/parsing/common/extras/extras.rb
Overview
Extra information added to the prediction.
Instance Attribute Summary collapse
- #cropper ⇒ CropperExtra? readonly
- #full_text_ocr ⇒ Mindee::V1::Parsing::Common::Extras::FullTextOCRExtra readonly
- #rag ⇒ RAGExtra? readonly
Instance Method Summary collapse
-
#add_artificial_extra(raw_prediction) ⇒ Object
Adds artificial extra data for reconstructed extras.
-
#initialize(raw_prediction) ⇒ Extras
constructor
A new instance of Extras.
- #to_s ⇒ String
Constructor Details
#initialize(raw_prediction) ⇒ Extras
Returns a new instance of Extras.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mindee/v1/parsing/common/extras/extras.rb', line 20 def initialize(raw_prediction) if raw_prediction['cropper'] @cropper = Mindee::V1::Parsing::Common::Extras::CropperExtra.new(raw_prediction['cropper']) end if raw_prediction['full_text_ocr'] @full_text_ocr = Mindee::V1::Parsing::Common::Extras::FullTextOCRExtra.new( raw_prediction['full_text_ocr'] ) end @rag = Mindee::V1::Parsing::Common::Extras::RAGExtra.new(raw_prediction['rag']) if raw_prediction['rag'] raw_prediction.each do |key, value| instance_variable_set("@#{key}", value) unless ['cropper', 'full_text_ocr', 'rag'].include?(key.to_s) end end |
Instance Attribute Details
#cropper ⇒ CropperExtra? (readonly)
14 15 16 |
# File 'lib/mindee/v1/parsing/common/extras/extras.rb', line 14 def cropper @cropper end |
#full_text_ocr ⇒ Mindee::V1::Parsing::Common::Extras::FullTextOCRExtra (readonly)
16 17 18 |
# File 'lib/mindee/v1/parsing/common/extras/extras.rb', line 16 def full_text_ocr @full_text_ocr end |
#rag ⇒ RAGExtra? (readonly)
18 19 20 |
# File 'lib/mindee/v1/parsing/common/extras/extras.rb', line 18 def rag @rag end |
Instance Method Details
#add_artificial_extra(raw_prediction) ⇒ Object
Adds artificial extra data for reconstructed extras. Currently only used for full_text_ocr.
48 49 50 51 52 |
# File 'lib/mindee/v1/parsing/common/extras/extras.rb', line 48 def add_artificial_extra(raw_prediction) return unless raw_prediction['full_text_ocr'] @full_text_ocr << Mindee::V1::Parsing::Common::Extras::FullTextOCRExtra.new(raw_prediction) end |
#to_s ⇒ String
37 38 39 40 41 42 43 |
# File 'lib/mindee/v1/parsing/common/extras/extras.rb', line 37 def to_s out_str = String.new instance_variables.each do |var| out_str << "#{var}: #{instance_variable_get(var)}" end out_str end |