Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/code_samples/default_v2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mindee_client = Mindee::ClientV2.new(api_key: api_key)
params = Mindee::Input::InferenceParameters.new(
# ID of the model, required.
model_id,
# If set to `True`, will enable Retrieval-Augmented Generation.
# If set to `true`, will enable Retrieval-Augmented Generation.
rag: false,
)

Expand Down
4 changes: 2 additions & 2 deletions lib/mindee/input/local_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def valid_hmac_signature?(secret_key, signature)
end

# Deserializes a loaded response
# @param response_class [Parsing::V2::JobResponse, Parsing::V2::InferenceResponse] class to return.
# @param response_class [Parsing::V2::CommonResponse] class to return.
# @return [Parsing::V2::JobResponse, Parsing::V2::InferenceResponse]
def deserialize_response(response_class)
response_class.new(as_hash)
response_class.new(as_hash) # : Parsing::V2::JobResponse | Parsing::V2::InferenceResponse
rescue StandardError
raise Errors::MindeeInputError, 'Invalid response provided.'
end
Expand Down
4 changes: 2 additions & 2 deletions lib/mindee/input/sources/local_input_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def compress!(quality: 85, max_width: nil, max_height: nil, force_source_text: f
@io_stream.rewind
end

# Checks whether the file has source text if it is a pdf. False otherwise
# @return [bool] True if the file is a PDF and has source text.
# Checks whether the file has source text if it is a pdf. `false` otherwise
# @return [bool] `true` if the file is a PDF and has source text.
def source_text?
Mindee::PDF::PDFTools.source_text?(@io_stream)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mindee/parsing/universal/universal_object_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def method_missing(method_name, *_args)
#
# @param method_name [Symbol] The name of the method being checked.
# @param include_private [bool] Whether to include private methods in the check.
# @return [bool] True if the method can be responded to, false otherwise.
# @return [bool] `true` if the method can be responded to, false otherwise.
def respond_to_missing?(method_name, include_private = false)
@all_values.key?(method_name.to_s) || super
end
Expand Down
10 changes: 5 additions & 5 deletions lib/mindee/parsing/v2/field/field_confidence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ def self.from_string(value)
end

# Check if this is a certain confidence level.
# @return [Boolean] True if confidence is certain.
# @return [Boolean] `true` if confidence is certain.
def certain?
@value == CERTAIN
end

# Check if this is a high confidence level.
# @return [Boolean] True if confidence is high.
# @return [Boolean] `true` if confidence is high.
def high?
@value == HIGH
end

# Check if this is a medium confidence level.
# @return [Boolean] True if confidence is medium.
# @return [Boolean] `true` if confidence is medium.
def medium?
@value == MEDIUM
end

# Check if this is a low confidence level.
# @return [Boolean] True if confidence is low.
# @return [Boolean] `true` if confidence is low.
def low?
@value == LOW
end
Expand All @@ -71,7 +71,7 @@ def to_s

# Compare two FieldConfidence instances.
# @param other [FieldConfidence] The other confidence to compare.
# @return [Boolean] True if they have the same value.
# @return [Boolean] `true` if they have the same value.
def ==(other)
other.is_a?(FieldConfidence) && @value == other.value
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mindee/parsing/v2/field/inference_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def method_missing(method_name, *args, &block)

# Check if method_missing should handle the method.
# @param method_name [Symbol] The method name.
# @return [Boolean] True if the method should be handled.
# @return [Boolean] `true` if the method should be handled.
def respond_to_missing?(method_name, include_private = false)
key?(method_name.to_s) || super
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mindee/parsing/v2/field/list_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def to_s
end

# Check if the list is empty.
# @return [Boolean] True if the list has no items.
# @return [Boolean] `true` if the list has no items.
def empty?
@items.empty?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mindee/parsing/v2/field/object_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def method_missing(method_name, ...)

# Check if method_missing should handle the method.
# @param method_name [Symbol] The method name.
# @return [Boolean] True if the method should be handled.
# @return [Boolean] `true` if the method should be handled.
def respond_to_missing?(method_name, include_private = false)
@fields.respond_to?(method_name) || super
end
Expand Down
4 changes: 2 additions & 2 deletions lib/mindee/pdf/pdf_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def to_io_stream(params = {})
# Checks a PDFs stream content for text operators
# See https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf page 243-251.
# @param [StringIO] stream Stream object from a PDFs page.
# @return [bool] True if a text operator is found in the stream.
# @return [bool] `true` if a text operator is found in the stream.
def self.stream_has_text?(stream)
data = stream.data
return false if data.nil? || data.empty?
Expand All @@ -55,7 +55,7 @@ def self.stream_has_text?(stream)

# Checks whether the file has source_text. Sends false if the file isn't a PDF.
# @param [StringIO] pdf_data Abinary-encoded stream representing the PDF file.
# @return [bool] True if the pdf has source text, false otherwise.
# @return [bool] `true` if the pdf has source text, false otherwise.
def self.source_text?(pdf_data)
begin
pdf_data.rewind
Expand Down
2 changes: 1 addition & 1 deletion sig/mindee/input/local_response.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Mindee
def self.process_secret_key: (String) -> String
def get_hmac_signature: (String) -> String
def valid_hmac_signature?: (String, String) -> bool
def deserialize_response: (singleton(Parsing::V2::JobResponse) | singleton(Parsing::V2::InferenceResponse))-> (Parsing::V2::JobResponse | Parsing::V2::InferenceResponse)
def deserialize_response: (singleton(Parsing::V2::CommonResponse))-> (Parsing::V2::JobResponse | Parsing::V2::InferenceResponse)
end
end
end
6 changes: 6 additions & 0 deletions spec/parsing/v2/inference_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def load_v2_inference(resource_path)
first_tax_item = taxes_list.items.first
expect(first_tax_item).to be_a(object_field)

expect(fields).to have_key('line_items')
expect(fields['line_items']).not_to be_nil
expect(fields['line_items']).to be_a(list_field)
expect(fields['line_items'][0]).to be_a(object_field)
expect(fields['line_items'][0]['quantity'].value).to eq(1.0)

tax_item_obj = first_tax_item
expect(tax_item_obj.fields.size).to eq(3)

Expand Down
Loading