Class: Mindee::V2::Product::Extraction::Params::ExtractionParameters
- Inherits:
-
Input::BaseParameters
- Object
- Input::BaseParameters
- Mindee::V2::Product::Extraction::Params::ExtractionParameters
- Defined in:
- lib/mindee/v2/product/extraction/params/extraction_parameters.rb
Overview
Parameters accepted by the extraction v2 endpoint.
Instance Attribute Summary collapse
-
#confidence ⇒ Boolean?
readonly
Boost the precision and accuracy of all extractions.
- #data_schema ⇒ DataSchemaField readonly
-
#polygon ⇒ Boolean?
readonly
Calculate bounding box polygons for all fields, and fill their
locationsattribute. -
#rag ⇒ Boolean?
readonly
Enhance extraction accuracy with Retrieval-Augmented Generation.
-
#raw_text ⇒ Boolean?
readonly
Extract the full text content from the document as strings, and fill the raw_text` attribute.
-
#text_context ⇒ String?
readonly
Additional text context used by the model during inference.
Attributes inherited from Input::BaseParameters
#close_file, #file_alias, #model_id, #polling_options, #webhook_ids
Class Method Summary collapse
-
.from_hash(params: {}) ⇒ ExtractionParameters
Loads a prediction from a Hash.
-
.slug ⇒ String
Slug for the endpoint.
Instance Method Summary collapse
-
#append_form_data(form_data) ⇒ Array
Appends inference-specific form data to the provided array.
-
#initialize(model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil) ⇒ ExtractionParameters
constructor
rubocop:disable Metrics/ParameterLists.
Methods inherited from Input::BaseParameters
load_from_hash, #slug, #validate_async_params
Constructor Details
#initialize(model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil) ⇒ ExtractionParameters
rubocop:disable Metrics/ParameterLists
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 52 def initialize( model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil ) super( model_id, file_alias: file_alias, webhook_ids: webhook_ids, polling_options: , close_file: close_file ) @rag = rag @raw_text = raw_text @polygon = polygon @confidence = confidence @text_context = text_context @data_schema = DataSchema.new(data_schema) unless data_schema.nil? # rubocop:enable Metrics/ParameterLists end |
Instance Attribute Details
#confidence ⇒ Boolean? (readonly)
Returns Boost the precision and accuracy of all extractions. Calculate confidence scores for all fields, and fill their confidence attribute.
26 27 28 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 26 def confidence @confidence end |
#data_schema ⇒ DataSchemaField (readonly)
33 34 35 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 33 def data_schema @data_schema end |
#polygon ⇒ Boolean? (readonly)
Returns Calculate bounding box polygons for all fields,
and fill their locations attribute.
22 23 24 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 22 def polygon @polygon end |
#rag ⇒ Boolean? (readonly)
Returns Enhance extraction accuracy with Retrieval-Augmented Generation.
14 15 16 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 14 def rag @rag end |
#raw_text ⇒ Boolean? (readonly)
Returns Extract the full text content from the document as strings, and fill the raw_text` attribute.
18 19 20 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 18 def raw_text @raw_text end |
#text_context ⇒ String? (readonly)
Returns Additional text context used by the model during inference. Not recommended, for specific use only.
30 31 32 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 30 def text_context @text_context end |
Class Method Details
.from_hash(params: {}) ⇒ ExtractionParameters
Loads a prediction from a Hash.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 101 def self.from_hash(params: {}) rag = params.fetch(:rag, nil) raw_text = params.fetch(:raw_text, nil) polygon = params.fetch(:polygon, nil) confidence = params.fetch(:confidence, nil) base_params = load_from_hash(params: params) new_params = base_params.merge(rag: rag, raw_text: raw_text, polygon: polygon, confidence: confidence) model_id = new_params.fetch(:model_id) ExtractionParameters.new( model_id, rag: rag, raw_text: raw_text, polygon: polygon, confidence: confidence, file_alias: params.fetch(:file_alias, nil), webhook_ids: params.fetch(:webhook_ids, nil), close_file: params.fetch(:close_file, true) ) end |
.slug ⇒ String
Returns Slug for the endpoint.
36 37 38 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 36 def self.slug 'extraction' end |
Instance Method Details
#append_form_data(form_data) ⇒ Array
Appends inference-specific form data to the provided array.
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 85 def append_form_data(form_data) new_form_data = super new_form_data.push(['rag', @rag.to_s]) unless @rag.nil? new_form_data.push(['raw_text', @raw_text.to_s]) unless @raw_text.nil? new_form_data.push(['polygon', @polygon.to_s]) unless @polygon.nil? new_form_data.push(['confidence', @confidence.to_s]) unless @confidence.nil? new_form_data.push(['text_context', @text_context]) if @text_context new_form_data.push(['data_schema', @data_schema.to_s]) if @data_schema new_form_data end |