Class: Mindee::Parsing::Common::Inference
- Inherits:
-
Object
- Object
- Mindee::Parsing::Common::Inference
show all
- 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::Custom::CustomV1, Mindee::Product::DeliveryNote::DeliveryNoteV1, Mindee::Product::EU::DriverLicense::DriverLicenseV1, Mindee::Product::EU::LicensePlate::LicensePlateV1, Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV1, Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2, Mindee::Product::FR::BankStatement::BankStatementV1, Mindee::Product::FR::CarteGrise::CarteGriseV1, Mindee::Product::FR::CarteVitale::CarteVitaleV1, Mindee::Product::FR::EnergyBill::EnergyBillV1, Mindee::Product::FR::IdCard::IdCardV1, Mindee::Product::FR::IdCard::IdCardV2, Mindee::Product::FR::Payslip::PayslipV2, Mindee::Product::FinancialDocument::FinancialDocumentV1, Mindee::Product::Generated::GeneratedV1, Mindee::Product::IND::IndianPassport::IndianPassportV1, Mindee::Product::InternationalId::InternationalIdV1, 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::ProofOfAddress::ProofOfAddressV1, Mindee::Product::Receipt::ReceiptV4, Mindee::Product::Receipt::ReceiptV5, Mindee::Product::Resume::ResumeV1, Mindee::Product::US::BankCheck::BankCheckV1, Mindee::Product::US::DriverLicense::DriverLicenseV1, Mindee::Product::US::HealthcareCard::HealthcareCardV1, Mindee::Product::US::UsMail::UsMailV2, Mindee::Product::US::W9::W9V1
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(raw_prediction) ⇒ Inference
Returns a new instance of Inference.
22
23
24
25
26
|
# File 'lib/mindee/parsing/common/inference.rb', line 22
def initialize(raw_prediction)
@is_rotation_applied = raw_prediction['is_rotation_applied']
@product = Product.new(raw_prediction['product'])
@pages = []
end
|
Instance Attribute Details
#is_rotation_applied ⇒ Boolean
13
14
15
|
# File 'lib/mindee/parsing/common/inference.rb', line 13
def is_rotation_applied
@is_rotation_applied
end
|
15
16
17
|
# File 'lib/mindee/parsing/common/inference.rb', line 15
def pages
@pages
end
|
17
18
19
|
# File 'lib/mindee/parsing/common/inference.rb', line 17
def prediction
@prediction
end
|
19
20
21
|
# File 'lib/mindee/parsing/common/inference.rb', line 19
def product
@product
end
|
Instance Method Details
#to_s ⇒ String
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/mindee/parsing/common/inference.rb', line 29
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" : ''}"
out_str << "\nPage Predictions\n================\n\n" unless @pages.empty?
out_str << @pages.map(&:to_s).join("\n\n")
out_str.rstrip!
out_str
end
|