Class: Mindee::V1::Parsing::Common::Inference
- Inherits:
-
Object
- Object
- Mindee::V1::Parsing::Common::Inference
- Defined in:
- lib/mindee/v1/parsing/common/inference.rb
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
-
#endpoint_name ⇒ String
readonly
Name of the endpoint for this product.
-
#endpoint_version ⇒ String
readonly
Version for this product.
-
#extras ⇒ Mindee::V1::Parsing::Common::Extras::Extras
readonly
Potential Extras fields sent back along the prediction.
-
#has_async ⇒ bool
readonly
Whether this product has access to an asynchronous endpoint.
-
#has_sync ⇒ bool
readonly
Whether this product has access to synchronous endpoint.
- #is_rotation_applied ⇒ bool readonly
- #pages ⇒ Array<Mindee::V1::Parsing::Common::Page> readonly
- #prediction ⇒ Mindee::V1::Parsing::Common::Prediction readonly
- #product ⇒ Mindee::V1::Parsing::Common::Product readonly
Instance Method Summary collapse
-
#initialize(raw_prediction) ⇒ Inference
constructor
A new instance of Inference.
- #to_s ⇒ String
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 = [] # : Array[Page] @extras = Extras::Extras.new(raw_prediction['extras']) if raw_prediction.include?('extras') end |
Instance Attribute Details
#endpoint_name ⇒ String (readonly)
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 (readonly)
Version for this product.
26 27 28 |
# File 'lib/mindee/v1/parsing/common/inference.rb', line 26 def endpoint_version @endpoint_version end |
#extras ⇒ Mindee::V1::Parsing::Common::Extras::Extras (readonly)
Returns Potential Extras fields sent back along the prediction.
34 35 36 |
# File 'lib/mindee/v1/parsing/common/inference.rb', line 34 def extras @extras end |
#has_async ⇒ bool (readonly)
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 (readonly)
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 (readonly)
14 15 16 |
# File 'lib/mindee/v1/parsing/common/inference.rb', line 14 def is_rotation_applied @is_rotation_applied end |
#pages ⇒ Array<Mindee::V1::Parsing::Common::Page> (readonly)
16 17 18 |
# File 'lib/mindee/v1/parsing/common/inference.rb', line 16 def pages @pages end |
#prediction ⇒ Mindee::V1::Parsing::Common::Prediction (readonly)
18 19 20 |
# File 'lib/mindee/v1/parsing/common/inference.rb', line 18 def prediction @prediction end |
#product ⇒ Mindee::V1::Parsing::Common::Product (readonly)
20 21 22 |
# File 'lib/mindee/v1/parsing/common/inference.rb', line 20 def product @product end |
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 |