Class: Mindee::V1::Parsing::Common::OCR::OCRWord

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/v1/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)


24
25
26
27
28
29
# File 'lib/mindee/v1/parsing/common/ocr/ocr.rb', line 24

def initialize(prediction)
  @text = prediction['text']
  @confidence = prediction['confidence']
  @polygon = Mindee::Geometry::Polygon.new(prediction['polygon'])
  @bounding_box = Geometry.get_bounding_box(@polygon) unless @polygon.nil? || @polygon.empty?
end

Instance Attribute Details

#bounding_boxMindee::Geometry::Quadrilateral (readonly)



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

def bounding_box
  @bounding_box
end

#confidenceFloat (readonly)

The confidence score, value will be between 0.0 and 1.0

Returns:

  • (Float)


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

def confidence
  @confidence
end

#polygonMindee::Geometry::Polygon (readonly)



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

def polygon
  @polygon
end

#textString (readonly)

Returns:

  • (String)


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

def text
  @text
end

Instance Method Details

#to_sString

Returns:

  • (String)


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

def to_s
  @text.to_s
end