Class: Mindee::Parsing::Custom::ListField
- Inherits:
-
Object
- Object
- Mindee::Parsing::Custom::ListField
- Defined in:
- lib/mindee/parsing/custom/list_field.rb
Overview
Field where actual values are kept in a list (custom docs).
Instance Attribute Summary collapse
-
#confidence ⇒ Float
The confidence score, value will be between 0.0 and 1.0.
-
#reconstructed ⇒ Boolean
readonly
true if the field was reconstructed or computed using other fields.
- #values ⇒ Array<Mindee::Parsing::Custom::ListFieldItem> readonly
Instance Method Summary collapse
- #contents_list ⇒ Array
- #contents_str(separator: ' ') ⇒ String
-
#initialize(prediction, page_id, reconstructed: false) ⇒ ListField
constructor
A new instance of ListField.
- #to_s ⇒ String
Constructor Details
#initialize(prediction, page_id, reconstructed: false) ⇒ ListField
Returns a new instance of ListField.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 49 def initialize(prediction, page_id, reconstructed: false) @values = [] @confidence = prediction['confidence'] page_id = prediction['page_id'] if page_id.nil? && prediction.include?('page_id') @reconstructed = reconstructed prediction['values'].each do |field| page_id = field['page_id'] if field.include?('page_id') @values.push(ListFieldItem.new(field, page_id: page_id)) end end |
Instance Attribute Details
#confidence ⇒ Float
The confidence score, value will be between 0.0 and 1.0
44 45 46 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 44 def confidence @confidence end |
#reconstructed ⇒ Boolean (readonly)
true if the field was reconstructed or computed using other fields.
41 42 43 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 41 def reconstructed @reconstructed end |
#values ⇒ Array<Mindee::Parsing::Custom::ListFieldItem> (readonly)
38 39 40 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 38 def values @values end |
Instance Method Details
#contents_list ⇒ Array
62 63 64 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 62 def contents_list @values.map(&:content) end |
#contents_str(separator: ' ') ⇒ String
67 68 69 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 67 def contents_str(separator: ' ') @values.map(&:to_s).join(separator) end |
#to_s ⇒ String
72 73 74 |
# File 'lib/mindee/parsing/custom/list_field.rb', line 72 def to_s contents_str(separator: ' ') end |