Class: Mindee::Parsing::V2::InferenceResult
- Inherits:
-
Object
- Object
- Mindee::Parsing::V2::InferenceResult
- Defined in:
- lib/mindee/parsing/v2/inference_result.rb
Overview
Wrapper for the result of a V2 inference request.
Instance Attribute Summary collapse
-
#fields ⇒ Mindee::Parsing::V2::Field::InferenceFields
readonly
Fields produced by the model.
-
#raw_text ⇒ Mindee::Parsing::V2::RawText?
readonly
Optional extra data.
Instance Method Summary collapse
-
#initialize(server_response) ⇒ InferenceResult
constructor
A new instance of InferenceResult.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(server_response) ⇒ InferenceResult
Returns a new instance of InferenceResult.
17 18 19 20 21 22 23 |
# File 'lib/mindee/parsing/v2/inference_result.rb', line 17 def initialize(server_response) raise ArgumentError, 'server_response must be a Hash' unless server_response.is_a?(Hash) @fields = Field::InferenceFields.new(server_response['fields']) @raw_text = server_response['raw_text'] ? RawText.new(server_response['raw_text']) : nil end |
Instance Attribute Details
#fields ⇒ Mindee::Parsing::V2::Field::InferenceFields (readonly)
Returns Fields produced by the model.
12 13 14 |
# File 'lib/mindee/parsing/v2/inference_result.rb', line 12 def fields @fields end |
#raw_text ⇒ Mindee::Parsing::V2::RawText? (readonly)
Returns Optional extra data.
14 15 16 |
# File 'lib/mindee/parsing/v2/inference_result.rb', line 14 def raw_text @raw_text end |
Instance Method Details
#to_s ⇒ String
String representation.
27 28 29 30 31 32 33 34 |
# File 'lib/mindee/parsing/v2/inference_result.rb', line 27 def to_s parts = [ 'Fields', '======', @fields.to_s, ] parts.join("\n") end |