Class: Mindee::V2::Product::Extraction::ExtractionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/v2/product/extraction/extraction_result.rb

Overview

Result of an extraction utility inference.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ ExtractionResult

Returns a new instance of ExtractionResult.

Parameters:

  • server_response (Hash)

    Hash version of the JSON returned by the API.

Raises:

  • (ArgumentError)


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

#fieldsMindee::V2::Parsing::Field::InferenceFields (readonly)

Returns Fields produced by the model.

Returns:



12
13
14
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 12

def fields
  @fields
end

#ragMindee::V2::Parsing::RAGMetadata? (readonly)

Returns Optional RAG metadata.

Returns:



16
17
18
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 16

def rag
  @rag
end

#raw_textMindee::V2::Parsing::RawText? (readonly)

Returns Optional extra data.

Returns:



14
15
16
# File 'lib/mindee/v2/product/extraction/extraction_result.rb', line 14

def raw_text
  @raw_text
end

Instance Method Details

#to_sString

String representation.

Returns:

  • (String)


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