Class: Mindee::Parsing::Common::Ocr::OcrWord

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/parsing/common/ocr/ocr.rb

Overview

A single word.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction) ⇒ OcrWord

Returns a new instance of OcrWord.

Parameters:

  • prediction (Hash)


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_boxMindee::Geometry::Quadrilateral (readonly)



18
19
20
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 18

def bounding_box
  @bounding_box
end

#confidenceFloat

The confidence score, value will be between 0.0 and 1.0

Returns:

  • (Float)


14
15
16
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 14

def confidence
  @confidence
end

#polygonMindee::Geometry::Polygon (readonly)



20
21
22
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 20

def polygon
  @polygon
end

#textString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 16

def text
  @text
end

Instance Method Details

#to_sString

Returns:

  • (String)


31
32
33
# File 'lib/mindee/parsing/common/ocr/ocr.rb', line 31

def to_s
  @text.to_s
end