Class: Mindee::V2::Product::Extraction::ExtractionResult
- Inherits:
-
Object
- Object
- Mindee::V2::Product::Extraction::ExtractionResult
- Defined in:
- lib/mindee/v2/product/extraction/extraction_result.rb
Overview
Result of an extraction utility inference.
Instance Attribute Summary collapse
-
#fields ⇒ Mindee::V2::Parsing::Field::InferenceFields
readonly
Fields produced by the model.
-
#rag ⇒ Mindee::V2::Parsing::RAGMetadata?
readonly
Optional RAG metadata.
-
#raw_text ⇒ Mindee::V2::Parsing::RawText?
readonly
Optional extra data.
Instance Method Summary collapse
-
#initialize(server_response) ⇒ ExtractionResult
constructor
A new instance of ExtractionResult.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(server_response) ⇒ ExtractionResult
Returns a new instance of ExtractionResult.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 19 def initialize(server_response) raise ArgumentError, 'server_response must be a Hash' unless server_response.is_a?(Hash) @fields = Parsing::Field::InferenceFields.new(server_response['fields']) @raw_text = server_response['raw_text'] ? Parsing::RawText.new(server_response['raw_text']) : nil return unless server_response.key?('rag') && server_response['rag'] @rag = Parsing::RAGMetadata.new(server_response['rag']) end |
Instance Attribute Details
#fields ⇒ Mindee::V2::Parsing::Field::InferenceFields (readonly)
Returns Fields produced by the model.
12 13 14 |
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 12 def fields @fields end |
#rag ⇒ Mindee::V2::Parsing::RAGMetadata? (readonly)
Returns Optional RAG metadata.
16 17 18 |
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 16 def rag @rag end |
#raw_text ⇒ Mindee::V2::Parsing::RawText? (readonly)
Returns Optional extra data.
14 15 16 |
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 14 def raw_text @raw_text end |
Instance Method Details
#to_s ⇒ String
String representation.
32 33 34 35 36 37 38 39 |
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 32 def to_s parts = [ 'Fields', '======', @fields.to_s, ] parts.join("\n") end |