Class: Mindee::Parsing::Custom::ListFieldItem

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/parsing/custom/list_field.rb

Overview

Field in a list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id: nil) ⇒ ListFieldItem

Returns a new instance of ListFieldItem.

Parameters:

  • prediction (Hash)


21
22
23
24
25
26
27
# File 'lib/mindee/parsing/custom/list_field.rb', line 21

def initialize(prediction, page_id: nil)
  @content = prediction['content']
  @confidence = prediction['confidence']
  @polygon = Geometry.polygon_from_prediction(prediction['polygon'])
  @bounding_box = Geometry.get_bounding_box(@polygon) unless @polygon.nil? || @polygon.empty?
  @page_id = page_id
end

Instance Attribute Details

#bounding_boxMindee::Geometry::Quadrilateral (readonly)



12
13
14
# File 'lib/mindee/parsing/custom/list_field.rb', line 12

def bounding_box
  @bounding_box
end

#confidenceFloat

The confidence score, value will be between 0.0 and 1.0

Returns:

  • (Float)


10
11
12
# File 'lib/mindee/parsing/custom/list_field.rb', line 10

def confidence
  @confidence
end

#contentArray, ... (readonly)

Returns:

  • (Array, Hash, String, nil)


16
17
18
# File 'lib/mindee/parsing/custom/list_field.rb', line 16

def content
  @content
end

#page_idInteger? (readonly)

Returns:

  • (Integer, nil)


18
19
20
# File 'lib/mindee/parsing/custom/list_field.rb', line 18

def page_id
  @page_id
end

#polygonMindee::Geometry::Polygon (readonly)



14
15
16
# File 'lib/mindee/parsing/custom/list_field.rb', line 14

def polygon
  @polygon
end

Instance Method Details

#to_sString

Returns:

  • (String)


30
31
32
# File 'lib/mindee/parsing/custom/list_field.rb', line 30

def to_s
  @content.to_s
end