mindee 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +57 -7
- data/bin/mindee.rb +160 -83
- data/docs/bank_account_details_v2.md +137 -0
- data/docs/bank_check_v1.md +179 -0
- data/docs/barcode_reader_v1.md +104 -0
- data/docs/carte_vitale_v1.md +123 -0
- data/docs/code_samples/barcode_reader_v1.txt +19 -0
- data/docs/code_samples/cropper_v1.txt +16 -0
- data/docs/code_samples/idcard_fr_v2.txt +19 -0
- data/docs/code_samples/invoice_splitter_v1_async.txt +6 -54
- data/docs/code_samples/multi_receipts_detector_v1.txt +19 -0
- data/docs/code_samples/us_w9_v1.txt +16 -0
- data/docs/cropper_v1.md +97 -0
- data/docs/custom_v1.md +101 -0
- data/docs/expense_receipts_v5.md +306 -0
- data/docs/financial_document_v1.md +384 -0
- data/docs/{ruby-getting-started.md → getting_started.md} +22 -6
- data/docs/idcard_fr_v2.md +253 -0
- data/docs/invoice_splitter_v1.md +85 -0
- data/docs/invoices_v4.md +369 -0
- data/docs/license_plates_v1.md +91 -0
- data/docs/multi_receipts_detector_v1.md +105 -0
- data/docs/passport_v1.md +186 -0
- data/docs/proof_of_address_v1.md +207 -0
- data/docs/us_driver_license_v1.md +268 -0
- data/docs/us_w9_v1.md +207 -0
- data/lib/mindee/client.rb +95 -16
- data/lib/mindee/geometry/quadrilateral.rb +5 -0
- data/lib/mindee/http/.rubocop.yml +8 -0
- data/lib/mindee/http/endpoint.rb +14 -6
- data/lib/mindee/http/error.rb +104 -0
- data/lib/mindee/http.rb +1 -0
- data/lib/mindee/input/sources.rb +84 -15
- data/lib/mindee/parsing/common/api_response.rb +11 -1
- data/lib/mindee/parsing/common/inference.rb +2 -2
- data/lib/mindee/parsing/common/ocr/ocr.rb +1 -0
- data/lib/mindee/parsing/common.rb +0 -1
- data/lib/mindee/parsing/standard/company_registration_field.rb +1 -1
- data/lib/mindee/parsing/standard/locale_field.rb +1 -1
- data/lib/mindee/parsing/standard/payment_details_field.rb +1 -1
- data/lib/mindee/parsing/standard/position_field.rb +10 -3
- data/lib/mindee/parsing/standard/{text_field.rb → string_field.rb} +1 -1
- data/lib/mindee/parsing/standard.rb +1 -1
- data/lib/mindee/pdf/pdf_processing.rb +2 -1
- data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +37 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +44 -0
- data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +32 -0
- data/lib/mindee/product/cropper/cropper_v1.rb +37 -0
- data/lib/mindee/product/cropper/cropper_v1_document.rb +13 -0
- data/lib/mindee/product/cropper/cropper_v1_page.rb +49 -0
- data/lib/mindee/product/custom/custom_v1.rb +1 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +1 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +2 -2
- data/lib/mindee/product/financial_document/financial_document_v1.rb +1 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +24 -24
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +1 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +6 -6
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +1 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +6 -6
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +1 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +6 -6
- data/lib/mindee/product/fr/id_card/id_card_v1.rb +1 -0
- data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +16 -16
- data/lib/mindee/product/fr/id_card/id_card_v2.rb +39 -0
- data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +107 -0
- data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +53 -0
- data/lib/mindee/product/invoice/invoice_v4.rb +1 -0
- data/lib/mindee/product/invoice/invoice_v4_document.rb +24 -24
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +1 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +5 -3
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +37 -0
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +35 -0
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +32 -0
- data/lib/mindee/product/passport/passport_v1.rb +1 -0
- data/lib/mindee/product/passport/passport_v1_document.rb +16 -16
- data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +1 -0
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +14 -14
- data/lib/mindee/product/receipt/receipt_v4_document.rb +6 -6
- data/lib/mindee/product/receipt/receipt_v5.rb +1 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +12 -12
- data/lib/mindee/product/us/bank_check/bank_check_v1.rb +1 -0
- data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +8 -8
- data/lib/mindee/product/us/driver_license/driver_license_v1.rb +1 -0
- data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +28 -28
- data/lib/mindee/product/us/w9/w9_v1.rb +39 -0
- data/lib/mindee/product/us/w9/w9_v1_document.rb +15 -0
- data/lib/mindee/product/us/w9/w9_v1_page.rb +102 -0
- data/lib/mindee/product.rb +5 -0
- data/lib/mindee/version.rb +5 -1
- data/lib/mindee.rb +47 -0
- metadata +43 -9
- data/docs/ruby-api-builder.md +0 -123
- data/docs/ruby-invoice-ocr.md +0 -271
- data/docs/ruby-passport-ocr.md +0 -165
- data/docs/ruby-receipt-ocr.md +0 -196
- data/lib/mindee/parsing/common/error.rb +0 -24
|
@@ -11,7 +11,7 @@ module Mindee
|
|
|
11
11
|
include Mindee::Parsing::Standard
|
|
12
12
|
|
|
13
13
|
# Locale information.
|
|
14
|
-
# @return [Mindee::Parsing::Standard::
|
|
14
|
+
# @return [Mindee::Parsing::Standard::LocaleField]
|
|
15
15
|
attr_reader :locale
|
|
16
16
|
# The nature of the invoice.
|
|
17
17
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
|
@@ -29,10 +29,10 @@ module Mindee
|
|
|
29
29
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
30
30
|
attr_reader :date
|
|
31
31
|
# The invoice number.
|
|
32
|
-
# @return [Mindee::Parsing::Standard::
|
|
32
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
33
33
|
attr_reader :invoice_number
|
|
34
34
|
# List of Reference numbers including PO number.
|
|
35
|
-
# @return [Mindee::Parsing::Standard::
|
|
35
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
36
36
|
attr_reader :reference_numbers
|
|
37
37
|
# The due date of the invoice.
|
|
38
38
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
@@ -41,25 +41,25 @@ module Mindee
|
|
|
41
41
|
# @return [Mindee::Parsing::Standard::Taxes]
|
|
42
42
|
attr_reader :taxes
|
|
43
43
|
# The name of the customer.
|
|
44
|
-
# @return [Mindee::Parsing::Standard::
|
|
44
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
45
45
|
attr_reader :customer_name
|
|
46
46
|
# The address of the customer.
|
|
47
|
-
# @return [Mindee::Parsing::Standard::
|
|
47
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
48
48
|
attr_reader :customer_address
|
|
49
49
|
# The company registration information for the customer.
|
|
50
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
50
|
+
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
|
51
51
|
attr_reader :customer_company_registrations
|
|
52
52
|
# The supplier's name.
|
|
53
|
-
# @return [Mindee::Parsing::Standard::
|
|
53
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
54
54
|
attr_reader :supplier_name
|
|
55
55
|
# The supplier's address.
|
|
56
|
-
# @return [Mindee::Parsing::Standard::
|
|
56
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
57
57
|
attr_reader :supplier_address
|
|
58
58
|
# The payment information.
|
|
59
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
59
|
+
# @return [Array<Mindee::Parsing::Standard::PaymentDetailsField>]
|
|
60
60
|
attr_reader :supplier_payment_details
|
|
61
61
|
# The supplier's company registration information.
|
|
62
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
62
|
+
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
|
63
63
|
attr_reader :supplier_company_registrations
|
|
64
64
|
# Line items details.
|
|
65
65
|
# @return [Array<Mindee::InvoiceV4LineItem>]
|
|
@@ -69,33 +69,33 @@ module Mindee
|
|
|
69
69
|
# @param page_id [Integer, nil]
|
|
70
70
|
def initialize(prediction, page_id)
|
|
71
71
|
super()
|
|
72
|
-
@locale =
|
|
72
|
+
@locale = LocaleField.new(prediction['locale'])
|
|
73
73
|
@document_type = ClassificationField.new(prediction['document_type'], page_id)
|
|
74
74
|
@total_amount = AmountField.new(prediction['total_amount'], page_id)
|
|
75
75
|
@total_net = AmountField.new(prediction['total_net'], page_id)
|
|
76
|
-
@customer_address =
|
|
77
|
-
@customer_name =
|
|
76
|
+
@customer_address = StringField.new(prediction['customer_address'], page_id)
|
|
77
|
+
@customer_name = StringField.new(prediction['customer_name'], page_id)
|
|
78
78
|
@date = DateField.new(prediction['date'], page_id)
|
|
79
79
|
@due_date = DateField.new(prediction['due_date'], page_id)
|
|
80
|
-
@invoice_number =
|
|
81
|
-
@supplier_name =
|
|
82
|
-
@supplier_address =
|
|
80
|
+
@invoice_number = StringField.new(prediction['invoice_number'], page_id)
|
|
81
|
+
@supplier_name = StringField.new(prediction['supplier_name'], page_id)
|
|
82
|
+
@supplier_address = StringField.new(prediction['supplier_address'], page_id)
|
|
83
83
|
@reference_numbers = []
|
|
84
84
|
prediction['reference_numbers'].each do |item|
|
|
85
|
-
@reference_numbers.push(
|
|
85
|
+
@reference_numbers.push(StringField.new(item, page_id))
|
|
86
86
|
end
|
|
87
87
|
@customer_company_registrations = []
|
|
88
88
|
prediction['customer_company_registrations'].each do |item|
|
|
89
|
-
@customer_company_registrations.push(
|
|
89
|
+
@customer_company_registrations.push(CompanyRegistrationField.new(item, page_id))
|
|
90
90
|
end
|
|
91
91
|
@taxes = Taxes.new(prediction['taxes'], page_id)
|
|
92
92
|
@supplier_payment_details = []
|
|
93
93
|
prediction['supplier_payment_details'].each do |item|
|
|
94
|
-
@supplier_payment_details.push(
|
|
94
|
+
@supplier_payment_details.push(PaymentDetailsField.new(item, page_id))
|
|
95
95
|
end
|
|
96
96
|
@supplier_company_registrations = []
|
|
97
97
|
prediction['supplier_company_registrations'].each do |item|
|
|
98
|
-
@supplier_company_registrations.push(
|
|
98
|
+
@supplier_company_registrations.push(CompanyRegistrationField.new(item, page_id))
|
|
99
99
|
end
|
|
100
100
|
@total_tax = AmountField.new(
|
|
101
101
|
{ value: nil, confidence: 0.0 }, page_id
|
|
@@ -168,7 +168,7 @@ module Mindee
|
|
|
168
168
|
|
|
169
169
|
total_excl = {
|
|
170
170
|
'value' => @total_amount.value - @taxes.map(&:value).sum,
|
|
171
|
-
'confidence' =>
|
|
171
|
+
'confidence' => StringField.array_confidence(@taxes) * @total_amount.confidence,
|
|
172
172
|
}
|
|
173
173
|
@total_net = AmountField.new(total_excl, page_id, reconstructed: true)
|
|
174
174
|
end
|
|
@@ -178,7 +178,7 @@ module Mindee
|
|
|
178
178
|
|
|
179
179
|
total_incl = {
|
|
180
180
|
'value' => @taxes.map(&:value).sum + @total_net.value,
|
|
181
|
-
'confidence' =>
|
|
181
|
+
'confidence' => StringField.array_confidence(@taxes) * @total_net.confidence,
|
|
182
182
|
}
|
|
183
183
|
@total_amount = AmountField.new(total_incl, page_id, reconstructed: true)
|
|
184
184
|
end
|
|
@@ -188,7 +188,7 @@ module Mindee
|
|
|
188
188
|
|
|
189
189
|
total_tax = {
|
|
190
190
|
'value' => @taxes.map(&:value).sum,
|
|
191
|
-
'confidence' =>
|
|
191
|
+
'confidence' => StringField.array_confidence(@taxes),
|
|
192
192
|
}
|
|
193
193
|
return unless total_tax['value'].positive?
|
|
194
194
|
|
|
@@ -200,7 +200,7 @@ module Mindee
|
|
|
200
200
|
|
|
201
201
|
total_tax = {
|
|
202
202
|
'value' => @total_amount.value - @total_net.value,
|
|
203
|
-
'confidence' =>
|
|
203
|
+
'confidence' => StringField.array_confidence(@taxes),
|
|
204
204
|
}
|
|
205
205
|
return unless total_tax['value'] >= 0
|
|
206
206
|
|
|
@@ -6,7 +6,7 @@ module Mindee
|
|
|
6
6
|
module Product
|
|
7
7
|
module InvoiceSplitter
|
|
8
8
|
# Page Group for Invoice Splitter class
|
|
9
|
-
class
|
|
9
|
+
class InvoiceSplitterV1PageGroup
|
|
10
10
|
# @return[Array<Integer>]
|
|
11
11
|
attr_reader :page_indexes
|
|
12
12
|
|
|
@@ -29,7 +29,7 @@ module Mindee
|
|
|
29
29
|
|
|
30
30
|
# Invoice Splitter V1 document prediction.
|
|
31
31
|
class InvoiceSplitterV1Document < Mindee::Parsing::Common::Prediction
|
|
32
|
-
# @return[Array<Mindee::Product::
|
|
32
|
+
# @return[Array<Mindee::Product::InvoiceSplitterV1PageGroup>]
|
|
33
33
|
attr_reader :invoice_page_groups
|
|
34
34
|
|
|
35
35
|
# @param prediction [Hash]
|
|
@@ -39,12 +39,14 @@ module Mindee
|
|
|
39
39
|
construct_invoice_page_groups_from_prediction(prediction)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# Reconstructs the page groups of a prediction
|
|
43
|
+
# @param prediction [hash]
|
|
42
44
|
def construct_invoice_page_groups_from_prediction(prediction)
|
|
43
45
|
@invoice_page_groups = []
|
|
44
46
|
return unless prediction.key?('invoice_page_groups') && prediction['invoice_page_groups'].any?
|
|
45
47
|
|
|
46
48
|
prediction['invoice_page_groups'].each do |page_group_prediction|
|
|
47
|
-
@invoice_page_groups.append(
|
|
49
|
+
@invoice_page_groups.append(InvoiceSplitterV1PageGroup.new(page_group_prediction))
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing'
|
|
4
|
+
require_relative 'multi_receipts_detector_v1_document'
|
|
5
|
+
require_relative 'multi_receipts_detector_v1_page'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module Product
|
|
9
|
+
# Multi Receipts Detector module.
|
|
10
|
+
module MultiReceiptsDetector
|
|
11
|
+
# Multi Receipts Detector V1 prediction inference.
|
|
12
|
+
class MultiReceiptsDetectorV1 < Mindee::Parsing::Common::Inference
|
|
13
|
+
@endpoint_name = 'multi_receipts_detector'
|
|
14
|
+
@endpoint_version = '1'
|
|
15
|
+
|
|
16
|
+
# @param prediction [Hash]
|
|
17
|
+
def initialize(prediction)
|
|
18
|
+
super
|
|
19
|
+
@prediction = MultiReceiptsDetectorV1Document.new(prediction['prediction'], nil)
|
|
20
|
+
@pages = []
|
|
21
|
+
prediction['pages'].each do |page|
|
|
22
|
+
@pages.push(MultiReceiptsDetectorV1Page.new(page))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class << self
|
|
27
|
+
# Name of the endpoint for this product.
|
|
28
|
+
# @return [String]
|
|
29
|
+
attr_reader :endpoint_name
|
|
30
|
+
# Version for this product.
|
|
31
|
+
# @return [String]
|
|
32
|
+
attr_reader :endpoint_version
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module Product
|
|
7
|
+
module MultiReceiptsDetector
|
|
8
|
+
# Multi Receipts Detector V1 document prediction.
|
|
9
|
+
class MultiReceiptsDetectorV1Document < Mindee::Parsing::Common::Prediction
|
|
10
|
+
include Mindee::Parsing::Standard
|
|
11
|
+
# Positions of the receipts on the document.
|
|
12
|
+
# @return [Array<Mindee::Parsing::Standard::PositionField>]
|
|
13
|
+
attr_reader :receipts
|
|
14
|
+
|
|
15
|
+
# @param prediction [Hash]
|
|
16
|
+
# @param page_id [Integer, nil]
|
|
17
|
+
def initialize(prediction, page_id)
|
|
18
|
+
super()
|
|
19
|
+
@receipts = []
|
|
20
|
+
prediction['receipts'].each do |item|
|
|
21
|
+
@receipts.push(PositionField.new(item, page_id))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @return [String]
|
|
26
|
+
def to_s
|
|
27
|
+
receipts = @receipts.join("\n #{' ' * 18}")
|
|
28
|
+
out_str = String.new
|
|
29
|
+
out_str << "\n:List of Receipts: #{receipts}".rstrip
|
|
30
|
+
out_str[1..].to_s
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing'
|
|
4
|
+
require_relative 'multi_receipts_detector_v1_document'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module Product
|
|
8
|
+
module MultiReceiptsDetector
|
|
9
|
+
# Multi Receipts Detector V1 page.
|
|
10
|
+
class MultiReceiptsDetectorV1Page < Mindee::Parsing::Common::Page
|
|
11
|
+
# @param prediction [Hash]
|
|
12
|
+
def initialize(prediction)
|
|
13
|
+
super(prediction)
|
|
14
|
+
@prediction = MultiReceiptsDetectorV1PagePrediction.new(
|
|
15
|
+
prediction['prediction'],
|
|
16
|
+
prediction['id']
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Multi Receipts Detector V1 page prediction.
|
|
22
|
+
class MultiReceiptsDetectorV1PagePrediction < MultiReceiptsDetectorV1Document
|
|
23
|
+
# @return [String]
|
|
24
|
+
def to_s
|
|
25
|
+
out_str = String.new
|
|
26
|
+
out_str << "\n#{super}"
|
|
27
|
+
out_str
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -12,34 +12,34 @@ module Mindee
|
|
|
12
12
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
13
13
|
attr_reader :birth_date
|
|
14
14
|
# The place of birth of the passport holder.
|
|
15
|
-
# @return [Mindee::Parsing::Standard::
|
|
15
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
16
16
|
attr_reader :birth_place
|
|
17
17
|
# The country's 3 letter code (ISO 3166-1 alpha-3).
|
|
18
|
-
# @return [Mindee::Parsing::Standard::
|
|
18
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
19
19
|
attr_reader :country
|
|
20
20
|
# The expiry date of the passport.
|
|
21
21
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
22
22
|
attr_reader :expiry_date
|
|
23
23
|
# The gender of the passport holder.
|
|
24
|
-
# @return [Mindee::Parsing::Standard::
|
|
24
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
25
25
|
attr_reader :gender
|
|
26
26
|
# The given name(s) of the passport holder.
|
|
27
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
27
|
+
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
|
28
28
|
attr_reader :given_names
|
|
29
29
|
# The passport's identification number.
|
|
30
|
-
# @return [Mindee::Parsing::Standard::
|
|
30
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
31
31
|
attr_reader :id_number
|
|
32
32
|
# The date the passport was issued.
|
|
33
33
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
34
34
|
attr_reader :issuance_date
|
|
35
35
|
# Machine Readable Zone, first line
|
|
36
|
-
# @return [Mindee::Parsing::Standard::
|
|
36
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
37
37
|
attr_reader :mrz1
|
|
38
38
|
# Machine Readable Zone, second line
|
|
39
|
-
# @return [Mindee::Parsing::Standard::
|
|
39
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
40
40
|
attr_reader :mrz2
|
|
41
41
|
# The surname of the passport holder.
|
|
42
|
-
# @return [Mindee::Parsing::Standard::
|
|
42
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
43
43
|
attr_reader :surname
|
|
44
44
|
|
|
45
45
|
# @param prediction [Hash]
|
|
@@ -47,19 +47,19 @@ module Mindee
|
|
|
47
47
|
def initialize(prediction, page_id)
|
|
48
48
|
super()
|
|
49
49
|
@birth_date = DateField.new(prediction['birth_date'], page_id)
|
|
50
|
-
@birth_place =
|
|
51
|
-
@country =
|
|
50
|
+
@birth_place = StringField.new(prediction['birth_place'], page_id)
|
|
51
|
+
@country = StringField.new(prediction['country'], page_id)
|
|
52
52
|
@expiry_date = DateField.new(prediction['expiry_date'], page_id)
|
|
53
|
-
@gender =
|
|
53
|
+
@gender = StringField.new(prediction['gender'], page_id)
|
|
54
54
|
@given_names = []
|
|
55
55
|
prediction['given_names'].each do |item|
|
|
56
|
-
@given_names.push(
|
|
56
|
+
@given_names.push(StringField.new(item, page_id))
|
|
57
57
|
end
|
|
58
|
-
@id_number =
|
|
58
|
+
@id_number = StringField.new(prediction['id_number'], page_id)
|
|
59
59
|
@issuance_date = DateField.new(prediction['issuance_date'], page_id)
|
|
60
|
-
@mrz1 =
|
|
61
|
-
@mrz2 =
|
|
62
|
-
@surname =
|
|
60
|
+
@mrz1 = StringField.new(prediction['mrz1'], page_id)
|
|
61
|
+
@mrz2 = StringField.new(prediction['mrz2'], page_id)
|
|
62
|
+
@surname = StringField.new(prediction['surname'], page_id)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
# @return [String]
|
|
@@ -15,25 +15,25 @@ module Mindee
|
|
|
15
15
|
# @return [Array<Mindee::Parsing::Standard::DateField>]
|
|
16
16
|
attr_reader :dates
|
|
17
17
|
# The address of the document's issuer.
|
|
18
|
-
# @return [Mindee::Parsing::Standard::
|
|
18
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
19
19
|
attr_reader :issuer_address
|
|
20
20
|
# List of company registrations found for the issuer.
|
|
21
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
21
|
+
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
|
22
22
|
attr_reader :issuer_company_registration
|
|
23
23
|
# The name of the person or company issuing the document.
|
|
24
|
-
# @return [Mindee::Parsing::Standard::
|
|
24
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
25
25
|
attr_reader :issuer_name
|
|
26
26
|
# The locale detected on the document.
|
|
27
|
-
# @return [Mindee::Parsing::Standard::
|
|
27
|
+
# @return [Mindee::Parsing::Standard::LocaleField]
|
|
28
28
|
attr_reader :locale
|
|
29
29
|
# The address of the recipient.
|
|
30
|
-
# @return [Mindee::Parsing::Standard::
|
|
30
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
31
31
|
attr_reader :recipient_address
|
|
32
32
|
# List of company registrations found for the recipient.
|
|
33
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
33
|
+
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
|
34
34
|
attr_reader :recipient_company_registration
|
|
35
35
|
# The name of the person or company receiving the document.
|
|
36
|
-
# @return [Mindee::Parsing::Standard::
|
|
36
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
37
37
|
attr_reader :recipient_name
|
|
38
38
|
|
|
39
39
|
# @param prediction [Hash]
|
|
@@ -45,19 +45,19 @@ module Mindee
|
|
|
45
45
|
prediction['dates'].each do |item|
|
|
46
46
|
@dates.push(DateField.new(item, page_id))
|
|
47
47
|
end
|
|
48
|
-
@issuer_address =
|
|
48
|
+
@issuer_address = StringField.new(prediction['issuer_address'], page_id)
|
|
49
49
|
@issuer_company_registration = []
|
|
50
50
|
prediction['issuer_company_registration'].each do |item|
|
|
51
|
-
@issuer_company_registration.push(
|
|
51
|
+
@issuer_company_registration.push(CompanyRegistrationField.new(item, page_id))
|
|
52
52
|
end
|
|
53
|
-
@issuer_name =
|
|
54
|
-
@locale =
|
|
55
|
-
@recipient_address =
|
|
53
|
+
@issuer_name = StringField.new(prediction['issuer_name'], page_id)
|
|
54
|
+
@locale = LocaleField.new(prediction['locale'], page_id)
|
|
55
|
+
@recipient_address = StringField.new(prediction['recipient_address'], page_id)
|
|
56
56
|
@recipient_company_registration = []
|
|
57
57
|
prediction['recipient_company_registration'].each do |item|
|
|
58
|
-
@recipient_company_registration.push(
|
|
58
|
+
@recipient_company_registration.push(CompanyRegistrationField.new(item, page_id))
|
|
59
59
|
end
|
|
60
|
-
@recipient_name =
|
|
60
|
+
@recipient_name = StringField.new(prediction['recipient_name'], page_id)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# @return [String]
|
|
@@ -9,7 +9,7 @@ module Mindee
|
|
|
9
9
|
class ReceiptV4Document < Mindee::Parsing::Common::Prediction
|
|
10
10
|
include Mindee::Parsing::Standard
|
|
11
11
|
# Where the purchase was made, the language, and the currency.
|
|
12
|
-
# @return [Mindee::Parsing::Standard::
|
|
12
|
+
# @return [Mindee::Parsing::Standard::LocaleField]
|
|
13
13
|
attr_reader :locale
|
|
14
14
|
# Total including taxes
|
|
15
15
|
# @return [Mindee::Parsing::Standard::AmountField]
|
|
@@ -24,13 +24,13 @@ module Mindee
|
|
|
24
24
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
25
25
|
attr_reader :date
|
|
26
26
|
# The name of the supplier or merchant, as seen on the receipt.
|
|
27
|
-
# @return [Mindee::Parsing::Standard::
|
|
27
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
28
28
|
attr_reader :supplier
|
|
29
29
|
# List of taxes detected on the receipt.
|
|
30
30
|
# @return [Mindee::Parsing::Standard::Taxes]
|
|
31
31
|
attr_reader :taxes
|
|
32
32
|
# Time as seen on the receipt in HH:MM format.
|
|
33
|
-
# @return [Mindee::Parsing::Standard::
|
|
33
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
34
34
|
attr_reader :time
|
|
35
35
|
# The receipt category among predefined classes.
|
|
36
36
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
|
@@ -49,7 +49,7 @@ module Mindee
|
|
|
49
49
|
# @param page_id [Integer, nil]
|
|
50
50
|
def initialize(prediction, page_id)
|
|
51
51
|
super()
|
|
52
|
-
@locale =
|
|
52
|
+
@locale = LocaleField.new(prediction['locale'])
|
|
53
53
|
@total_amount = AmountField.new(prediction['total_amount'], page_id)
|
|
54
54
|
@total_net = AmountField.new(prediction['total_net'], page_id)
|
|
55
55
|
@total_tax = AmountField.new(prediction['total_tax'], page_id)
|
|
@@ -58,8 +58,8 @@ module Mindee
|
|
|
58
58
|
@category = ClassificationField.new(prediction['category'], page_id)
|
|
59
59
|
@subcategory = ClassificationField.new(prediction['subcategory'], page_id)
|
|
60
60
|
@document_type = ClassificationField.new(prediction['document_type'], page_id)
|
|
61
|
-
@supplier =
|
|
62
|
-
@time =
|
|
61
|
+
@supplier = StringField.new(prediction['supplier'], page_id)
|
|
62
|
+
@time = StringField.new(prediction['time'], page_id)
|
|
63
63
|
@taxes = Taxes.new(prediction['taxes'], page_id)
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -22,28 +22,28 @@ module Mindee
|
|
|
22
22
|
# @return [Array<Mindee::Product::Receipt::ReceiptV5LineItem>]
|
|
23
23
|
attr_reader :line_items
|
|
24
24
|
# The locale detected on the document.
|
|
25
|
-
# @return [Mindee::Parsing::Standard::
|
|
25
|
+
# @return [Mindee::Parsing::Standard::LocaleField]
|
|
26
26
|
attr_reader :locale
|
|
27
27
|
# The purchase subcategory among predefined classes for transport and food.
|
|
28
28
|
# @return [Mindee::Parsing::Standard::ClassificationField]
|
|
29
29
|
attr_reader :subcategory
|
|
30
30
|
# The address of the supplier or merchant.
|
|
31
|
-
# @return [Mindee::Parsing::Standard::
|
|
31
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
32
32
|
attr_reader :supplier_address
|
|
33
33
|
# List of company registrations associated to the supplier.
|
|
34
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
34
|
+
# @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
|
|
35
35
|
attr_reader :supplier_company_registrations
|
|
36
36
|
# The name of the supplier or merchant.
|
|
37
|
-
# @return [Mindee::Parsing::Standard::
|
|
37
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
38
38
|
attr_reader :supplier_name
|
|
39
39
|
# The phone number of the supplier or merchant.
|
|
40
|
-
# @return [Mindee::Parsing::Standard::
|
|
40
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
41
41
|
attr_reader :supplier_phone_number
|
|
42
42
|
# List of tax lines information.
|
|
43
43
|
# @return [Mindee::Parsing::Standard::Taxes]
|
|
44
44
|
attr_reader :taxes
|
|
45
45
|
# The time the purchase was made.
|
|
46
|
-
# @return [Mindee::Parsing::Standard::
|
|
46
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
47
47
|
attr_reader :time
|
|
48
48
|
# The total amount of tip and gratuity.
|
|
49
49
|
# @return [Mindee::Parsing::Standard::AmountField]
|
|
@@ -69,17 +69,17 @@ module Mindee
|
|
|
69
69
|
prediction['line_items'].each do |item|
|
|
70
70
|
@line_items.push(ReceiptV5LineItem.new(item, page_id))
|
|
71
71
|
end
|
|
72
|
-
@locale =
|
|
72
|
+
@locale = LocaleField.new(prediction['locale'], page_id)
|
|
73
73
|
@subcategory = ClassificationField.new(prediction['subcategory'], page_id)
|
|
74
|
-
@supplier_address =
|
|
74
|
+
@supplier_address = StringField.new(prediction['supplier_address'], page_id)
|
|
75
75
|
@supplier_company_registrations = []
|
|
76
76
|
prediction['supplier_company_registrations'].each do |item|
|
|
77
|
-
@supplier_company_registrations.push(
|
|
77
|
+
@supplier_company_registrations.push(CompanyRegistrationField.new(item, page_id))
|
|
78
78
|
end
|
|
79
|
-
@supplier_name =
|
|
80
|
-
@supplier_phone_number =
|
|
79
|
+
@supplier_name = StringField.new(prediction['supplier_name'], page_id)
|
|
80
|
+
@supplier_phone_number = StringField.new(prediction['supplier_phone_number'], page_id)
|
|
81
81
|
@taxes = Taxes.new(prediction['taxes'], page_id)
|
|
82
|
-
@time =
|
|
82
|
+
@time = StringField.new(prediction['time'], page_id)
|
|
83
83
|
@tip = AmountField.new(prediction['tip'], page_id)
|
|
84
84
|
@total_amount = AmountField.new(prediction['total_amount'], page_id)
|
|
85
85
|
@total_net = AmountField.new(prediction['total_net'], page_id)
|
|
@@ -10,37 +10,37 @@ module Mindee
|
|
|
10
10
|
class BankCheckV1Document < Mindee::Parsing::Common::Prediction
|
|
11
11
|
include Mindee::Parsing::Standard
|
|
12
12
|
# The check payer's account number.
|
|
13
|
-
# @return [Mindee::Parsing::Standard::
|
|
13
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
14
14
|
attr_reader :account_number
|
|
15
15
|
# The amount of the check.
|
|
16
16
|
# @return [Mindee::Parsing::Standard::AmountField]
|
|
17
17
|
attr_reader :amount
|
|
18
18
|
# The issuer's check number.
|
|
19
|
-
# @return [Mindee::Parsing::Standard::
|
|
19
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
20
20
|
attr_reader :check_number
|
|
21
21
|
# The date the check was issued.
|
|
22
22
|
# @return [Mindee::Parsing::Standard::DateField]
|
|
23
23
|
attr_reader :date
|
|
24
24
|
# List of the check's payees (recipients).
|
|
25
|
-
# @return [Array<Mindee::Parsing::Standard::
|
|
25
|
+
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
|
26
26
|
attr_reader :payees
|
|
27
27
|
# The check issuer's routing number.
|
|
28
|
-
# @return [Mindee::Parsing::Standard::
|
|
28
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
29
29
|
attr_reader :routing_number
|
|
30
30
|
|
|
31
31
|
# @param prediction [Hash]
|
|
32
32
|
# @param page_id [Integer, nil]
|
|
33
33
|
def initialize(prediction, page_id)
|
|
34
34
|
super()
|
|
35
|
-
@account_number =
|
|
35
|
+
@account_number = StringField.new(prediction['account_number'], page_id)
|
|
36
36
|
@amount = AmountField.new(prediction['amount'], page_id)
|
|
37
|
-
@check_number =
|
|
37
|
+
@check_number = StringField.new(prediction['check_number'], page_id)
|
|
38
38
|
@date = DateField.new(prediction['date'], page_id)
|
|
39
39
|
@payees = []
|
|
40
40
|
prediction['payees'].each do |item|
|
|
41
|
-
@payees.push(
|
|
41
|
+
@payees.push(StringField.new(item, page_id))
|
|
42
42
|
end
|
|
43
|
-
@routing_number =
|
|
43
|
+
@routing_number = StringField.new(prediction['routing_number'], page_id)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# @return [String]
|