Class: Mindee::Parsing::Common::Inference
- Inherits:
-
Object
- Object
- Mindee::Parsing::Common::Inference
- Defined in:
- lib/mindee/parsing/common/inference.rb
Overview
Abstract class for prediction Inferences Holds prediction for a page or entire document.
Direct Known Subclasses
Mindee::Product::BarcodeReader::BarcodeReaderV1, Mindee::Product::BillOfLading::BillOfLadingV1, Mindee::Product::BusinessCard::BusinessCardV1, Mindee::Product::Cropper::CropperV1, Mindee::Product::DeliveryNote::DeliveryNoteV1, Mindee::Product::DriverLicense::DriverLicenseV1, Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV1, Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2, Mindee::Product::FR::BankStatement::BankStatementV2, Mindee::Product::FR::CarteGrise::CarteGriseV1, Mindee::Product::FR::EnergyBill::EnergyBillV1, Mindee::Product::FR::HealthCard::HealthCardV1, Mindee::Product::FR::IdCard::IdCardV1, Mindee::Product::FR::IdCard::IdCardV2, Mindee::Product::FR::Payslip::PayslipV2, Mindee::Product::FR::Payslip::PayslipV3, Mindee::Product::FinancialDocument::FinancialDocumentV1, Mindee::Product::IND::IndianPassport::IndianPassportV1, Mindee::Product::InternationalId::InternationalIdV2, Mindee::Product::Invoice::InvoiceV4, Mindee::Product::InvoiceSplitter::InvoiceSplitterV1, Mindee::Product::MultiReceiptsDetector::MultiReceiptsDetectorV1, Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1, Mindee::Product::Passport::PassportV1, Mindee::Product::Receipt::ReceiptV5, Mindee::Product::Resume::ResumeV1, Mindee::Product::US::BankCheck::BankCheckV1, Mindee::Product::US::HealthcareCard::HealthcareCardV1, Mindee::Product::US::UsMail::UsMailV2, Mindee::Product::US::UsMail::UsMailV3, Mindee::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.
-
#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::Parsing::Common::Page> readonly
- #prediction ⇒ Mindee::Parsing::Common::Prediction readonly
- #product ⇒ Mindee::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.
39 40 41 42 43 |
# File 'lib/mindee/parsing/common/inference.rb', line 39 def initialize(raw_prediction) @is_rotation_applied = raw_prediction['is_rotation_applied'] @product = Product.new(raw_prediction['product']) @pages = [] # : Array[Page] end |
Instance Attribute Details
#endpoint_name ⇒ String (readonly)
Name of the endpoint for this product.
22 23 24 |
# File 'lib/mindee/parsing/common/inference.rb', line 22 def endpoint_name @endpoint_name end |
#endpoint_version ⇒ String (readonly)
Version for this product.
25 26 27 |
# File 'lib/mindee/parsing/common/inference.rb', line 25 def endpoint_version @endpoint_version end |
#has_async ⇒ bool (readonly)
Whether this product has access to an asynchronous endpoint.
28 29 30 |
# File 'lib/mindee/parsing/common/inference.rb', line 28 def has_async @has_async end |
#has_sync ⇒ bool (readonly)
Whether this product has access to synchronous endpoint.
31 32 33 |
# File 'lib/mindee/parsing/common/inference.rb', line 31 def has_sync @has_sync end |
#is_rotation_applied ⇒ bool (readonly)
13 14 15 |
# File 'lib/mindee/parsing/common/inference.rb', line 13 def is_rotation_applied @is_rotation_applied end |
#pages ⇒ Array<Mindee::Parsing::Common::Page> (readonly)
15 16 17 |
# File 'lib/mindee/parsing/common/inference.rb', line 15 def pages @pages end |
#prediction ⇒ Mindee::Parsing::Common::Prediction (readonly)
17 18 19 |
# File 'lib/mindee/parsing/common/inference.rb', line 17 def prediction @prediction end |
#product ⇒ Mindee::Parsing::Common::Product (readonly)
19 20 21 |
# File 'lib/mindee/parsing/common/inference.rb', line 19 def product @product end |
Instance Method Details
#to_s ⇒ String
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mindee/parsing/common/inference.rb', line 46 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.to_s.size.positive? ? "#{@prediction}\n" : ''}" if @pages.any? { |page| !page.prediction.nil? } out_str << "\nPage Predictions\n================\n\n" out_str << @pages.map(&:to_s).join("\n\n") end out_str.rstrip! out_str end |