Class: Mindee::Parsing::Common::Ocr::OcrWord
- Inherits:
-
Object
- Object
- Mindee::Parsing::Common::Ocr::OcrWord
- Defined in:
- lib/mindee/parsing/common/ocr/ocr.rb
Overview
A single word.
Instance Attribute Summary collapse
- #bounding_box ⇒ Mindee::Geometry::Quadrilateral readonly
-
#confidence ⇒ Float
The confidence score, value will be between 0.0 and 1.0.
- #polygon ⇒ Mindee::Geometry::Polygon readonly
- #text ⇒ String readonly
Instance Method Summary collapse
-
#initialize(prediction) ⇒ OcrWord
constructor
A new instance of OcrWord.
- #to_s ⇒ String
Constructor Details
#initialize(prediction) ⇒ OcrWord
Returns a new instance of OcrWord.
23 24 25 26 27 28 |
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 23 def initialize(prediction) @text = prediction['text'] @confidence = prediction['confidence'] @polygon = Geometry.polygon_from_prediction(prediction['polygon']) @bounding_box = Geometry.get_bounding_box(@polygon) unless @polygon.nil? || @polygon.empty? end |
Instance Attribute Details
#bounding_box ⇒ Mindee::Geometry::Quadrilateral (readonly)
18 19 20 |
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 18 def bounding_box @bounding_box end |
#confidence ⇒ Float
The confidence score, value will be between 0.0 and 1.0
14 15 16 |
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 14 def confidence @confidence end |
#polygon ⇒ Mindee::Geometry::Polygon (readonly)
20 21 22 |
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 20 def polygon @polygon end |
#text ⇒ String (readonly)
16 17 18 |
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 16 def text @text end |
Instance Method Details
#to_s ⇒ String
31 32 33 |
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 31 def to_s @text.to_s end |