Class: Mindee::V1::Parsing::Common::Inference
- Inherits:
-
Object
- Object
- Mindee::V1::Parsing::Common::Inference
show all
- Defined in:
- lib/mindee/v1/parsing/common/inference.rb,
sig/mindee/v1/parsing/common/inference.rbs
Overview
Abstract class for prediction Inferences
Holds prediction for a page or entire document.
Direct Known Subclasses
Mindee::V1::Product::BarcodeReader::BarcodeReaderV1, Mindee::V1::Product::Cropper::CropperV1, Mindee::V1::Product::FR::BankAccountDetails::BankAccountDetailsV1, Mindee::V1::Product::FR::BankAccountDetails::BankAccountDetailsV2, Mindee::V1::Product::FR::BankStatement::BankStatementV2, Mindee::V1::Product::FR::IdCard::IdCardV1, Mindee::V1::Product::FR::IdCard::IdCardV2, Mindee::V1::Product::FinancialDocument::FinancialDocumentV1, Mindee::V1::Product::InternationalId::InternationalIdV2, Mindee::V1::Product::Invoice::InvoiceV4, Mindee::V1::Product::InvoiceSplitter::InvoiceSplitterV1, Mindee::V1::Product::MultiReceiptsDetector::MultiReceiptsDetectorV1, Mindee::V1::Product::Passport::PassportV1, Mindee::V1::Product::Receipt::ReceiptV5, Mindee::V1::Product::Resume::ResumeV1, Mindee::V1::Product::Universal::Universal
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(raw_prediction) ⇒ Inference
Returns a new instance of Inference.
42
43
44
45
46
47
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 42
def initialize(raw_prediction)
@is_rotation_applied = raw_prediction['is_rotation_applied']
@product = Product.new(raw_prediction['product'])
@pages = [] @extras = Extras::Extras.new(raw_prediction['extras']) if raw_prediction.include?('extras')
end
|
Instance Attribute Details
#endpoint_name ⇒ String
Name of the endpoint for this product.
23
24
25
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 23
def endpoint_name
@endpoint_name
end
|
#endpoint_version ⇒ String
Version for this product.
26
27
28
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 26
def endpoint_version
@endpoint_version
end
|
Returns Potential Extras fields sent back along the prediction.
34
35
36
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 34
def
@extras
end
|
#has_async ⇒ bool
Whether this product has access to an asynchronous endpoint.
29
30
31
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 29
def has_async
@has_async
end
|
#has_sync ⇒ bool
Whether this product has access to synchronous endpoint.
32
33
34
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 32
def has_sync
@has_sync
end
|
#is_rotation_applied ⇒ bool
14
15
16
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 14
def is_rotation_applied
@is_rotation_applied
end
|
16
17
18
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 16
def pages
@pages
end
|
18
19
20
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 18
def prediction
@prediction
end
|
20
21
22
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 20
def product
@product
end
|
Class Method Details
.endpoint_name ⇒ String?
7
|
# File 'sig/mindee/v1/parsing/common/inference.rbs', line 7
def self.endpoint_name: () -> String?
|
.endpoint_version ⇒ String?
9
|
# File 'sig/mindee/v1/parsing/common/inference.rbs', line 9
def self.endpoint_version: () -> String?
|
.has_async ⇒ Boolean
11
|
# File 'sig/mindee/v1/parsing/common/inference.rbs', line 11
def self.has_async: () -> bool
|
.has_sync ⇒ Boolean
13
|
# File 'sig/mindee/v1/parsing/common/inference.rbs', line 13
def self.has_sync: () -> bool
|
Instance Method Details
#to_s ⇒ String
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/mindee/v1/parsing/common/inference.rb', line 50
def to_s
is_rotation_applied = @is_rotation_applied ? 'Yes' : 'No'
out_str = String.new
out_str << "Inference\n#########"
out_str << "\n:Product: #{@product.name} v#{@product.version}"
out_str << "\n:Rotation applied: #{is_rotation_applied}"
out_str << "\n\nPrediction\n=========="
out_str << "\n#{"#{@prediction}\n" if @prediction.to_s.size.positive?}"
if @pages.any? { |page| !page.prediction.nil? }
out_str << "\nPage Predictions\n================\n\n"
out_str << @pages.join("\n\n")
end
out_str.rstrip!
out_str
end
|