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