mindee 2.2.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +31 -0
- data/README.md +29 -16
- data/bin/mindee.rb +23 -26
- data/docs/code_samples/bank_account_details_v1.txt +10 -5
- data/docs/code_samples/bank_account_details_v2.txt +19 -0
- data/docs/code_samples/bank_check_v1.txt +10 -5
- data/docs/code_samples/carte_vitale_v1.txt +10 -5
- data/docs/code_samples/custom_v1.txt +19 -10
- data/docs/code_samples/default.txt +10 -2
- data/docs/code_samples/expense_receipts_v4.txt +10 -5
- data/docs/code_samples/expense_receipts_v5.txt +11 -6
- data/docs/code_samples/financial_document_v1.txt +10 -5
- data/docs/code_samples/idcard_fr_v1.txt +10 -5
- data/docs/code_samples/invoice_splitter_v1_async.txt +66 -0
- data/docs/code_samples/invoices_v4.txt +10 -5
- data/docs/code_samples/license_plates_v1.txt +10 -5
- data/docs/code_samples/passport_v1.txt +10 -5
- data/docs/code_samples/proof_of_address_v1.txt +10 -5
- data/docs/ruby-api-builder.md +30 -31
- data/docs/ruby-getting-started.md +64 -23
- data/docs/ruby-invoice-ocr.md +70 -59
- data/docs/ruby-passport-ocr.md +49 -40
- data/docs/ruby-receipt-ocr.md +45 -32
- data/lib/mindee/client.rb +150 -148
- data/lib/mindee/geometry/min_max.rb +23 -0
- data/lib/mindee/geometry/point.rb +35 -0
- data/lib/mindee/geometry/polygon.rb +23 -0
- data/lib/mindee/geometry/quadrilateral.rb +45 -0
- data/lib/mindee/geometry/utils.rb +81 -0
- data/lib/mindee/geometry.rb +5 -116
- data/lib/mindee/http/endpoint.rb +123 -16
- data/lib/mindee/http.rb +3 -0
- data/lib/mindee/input/sources.rb +87 -73
- data/lib/mindee/parsing/common/api_response.rb +109 -0
- data/lib/mindee/parsing/common/document.rb +48 -0
- data/lib/mindee/parsing/common/error.rb +24 -0
- data/lib/mindee/parsing/common/inference.rb +43 -0
- data/lib/mindee/parsing/common/ocr/mvision_v1.rb +34 -0
- data/lib/mindee/parsing/common/ocr/ocr.rb +169 -0
- data/lib/mindee/parsing/common/ocr.rb +3 -0
- data/lib/mindee/parsing/common/orientation.rb +26 -0
- data/lib/mindee/parsing/common/page.rb +40 -0
- data/lib/mindee/parsing/common/prediction.rb +15 -0
- data/lib/mindee/parsing/common/product.rb +19 -0
- data/lib/mindee/parsing/common.rb +10 -0
- data/lib/mindee/parsing/custom/classification_field.rb +28 -0
- data/lib/mindee/parsing/custom/list_field.rb +76 -0
- data/lib/mindee/parsing/custom.rb +4 -0
- data/lib/mindee/parsing/standard/amount_field.rb +26 -0
- data/lib/mindee/parsing/standard/base_field.rb +104 -0
- data/lib/mindee/parsing/standard/classification_field.rb +16 -0
- data/lib/mindee/parsing/standard/company_registration_field.rb +21 -0
- data/lib/mindee/parsing/standard/date_field.rb +34 -0
- data/lib/mindee/parsing/standard/locale_field.rb +50 -0
- data/lib/mindee/parsing/standard/payment_details_field.rb +42 -0
- data/lib/mindee/parsing/standard/position_field.rb +44 -0
- data/lib/mindee/parsing/standard/tax_field.rb +108 -0
- data/lib/mindee/parsing/standard/text_field.rb +16 -0
- data/lib/mindee/parsing/standard.rb +12 -0
- data/lib/mindee/parsing.rb +3 -2
- data/lib/mindee/{input → pdf}/pdf_processing.rb +4 -32
- data/lib/mindee/pdf/pdf_tools.rb +34 -0
- data/lib/mindee/pdf.rb +3 -0
- data/lib/mindee/product/.rubocop.yml +5 -0
- data/lib/mindee/product/custom/custom_v1.rb +35 -0
- data/lib/mindee/product/custom/custom_v1_document.rb +60 -0
- data/lib/mindee/product/custom/custom_v1_page.rb +32 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +38 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +37 -0
- data/lib/mindee/product/eu/license_plate/license_plate_v1_page.rb +34 -0
- data/lib/mindee/product/financial_document/financial_document_v1.rb +36 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +188 -0
- data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +90 -0
- data/lib/mindee/product/financial_document/financial_document_v1_page.rb +32 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +38 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +43 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_page.rb +34 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +38 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +71 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +58 -0
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_page.rb +34 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +38 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +52 -0
- data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_page.rb +34 -0
- data/lib/mindee/product/fr/id_card/id_card_v1.rb +38 -0
- data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +82 -0
- data/lib/mindee/product/fr/id_card/id_card_v1_page.rb +48 -0
- data/lib/mindee/product/invoice/invoice_v4.rb +37 -0
- data/lib/mindee/product/invoice/invoice_v4_document.rb +212 -0
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +66 -0
- data/lib/mindee/product/invoice/invoice_v4_page.rb +32 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +36 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +65 -0
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +32 -0
- data/lib/mindee/product/passport/passport_v1.rb +36 -0
- data/lib/mindee/{parsing/prediction/fr/id_card/id_card_v1.rb → product/passport/passport_v1_document.rb} +45 -45
- data/lib/mindee/product/passport/passport_v1_page.rb +32 -0
- data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +36 -0
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +83 -0
- data/lib/mindee/product/proof_of_address/proof_of_address_v1_page.rb +32 -0
- data/lib/mindee/product/receipt/receipt_v4.rb +36 -0
- data/lib/mindee/product/receipt/receipt_v4_document.rb +86 -0
- data/lib/mindee/product/receipt/receipt_v4_page.rb +32 -0
- data/lib/mindee/product/receipt/receipt_v5.rb +36 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +138 -0
- data/lib/mindee/product/receipt/receipt_v5_line_item.rb +69 -0
- data/lib/mindee/product/receipt/receipt_v5_page.rb +32 -0
- data/lib/mindee/product/us/bank_check/bank_check_v1.rb +38 -0
- data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +73 -0
- data/lib/mindee/product/us/bank_check/bank_check_v1_page.rb +34 -0
- data/lib/mindee/product.rb +16 -0
- data/lib/mindee/version.rb +2 -1
- data/lib/mindee.rb +3 -1
- metadata +87 -38
- data/docs/code_samples/shipping_containers_v1.txt +0 -14
- data/lib/mindee/document_config.rb +0 -60
- data/lib/mindee/parsing/document.rb +0 -31
- data/lib/mindee/parsing/error.rb +0 -22
- data/lib/mindee/parsing/inference.rb +0 -53
- data/lib/mindee/parsing/page.rb +0 -46
- data/lib/mindee/parsing/prediction/base.rb +0 -30
- data/lib/mindee/parsing/prediction/common_fields/amount.rb +0 -21
- data/lib/mindee/parsing/prediction/common_fields/base.rb +0 -72
- data/lib/mindee/parsing/prediction/common_fields/company_registration.rb +0 -17
- data/lib/mindee/parsing/prediction/common_fields/date.rb +0 -30
- data/lib/mindee/parsing/prediction/common_fields/locale.rb +0 -45
- data/lib/mindee/parsing/prediction/common_fields/payment_details.rb +0 -33
- data/lib/mindee/parsing/prediction/common_fields/position.rb +0 -39
- data/lib/mindee/parsing/prediction/common_fields/tax.rb +0 -44
- data/lib/mindee/parsing/prediction/common_fields/text.rb +0 -12
- data/lib/mindee/parsing/prediction/common_fields.rb +0 -11
- data/lib/mindee/parsing/prediction/custom/custom_v1.rb +0 -58
- data/lib/mindee/parsing/prediction/custom/fields.rb +0 -91
- data/lib/mindee/parsing/prediction/eu/license_plate/license_plate_v1.rb +0 -34
- data/lib/mindee/parsing/prediction/financial_document/financial_document_v1.rb +0 -237
- data/lib/mindee/parsing/prediction/financial_document/financial_document_v1_line_item.rb +0 -58
- data/lib/mindee/parsing/prediction/fr/bank_account_details/bank_account_details_v1.rb +0 -40
- data/lib/mindee/parsing/prediction/fr/carte_vitale/carte_vitale_v1.rb +0 -49
- data/lib/mindee/parsing/prediction/invoice/invoice_v4.rb +0 -212
- data/lib/mindee/parsing/prediction/invoice/invoice_v4_line_item.rb +0 -58
- data/lib/mindee/parsing/prediction/passport/passport_v1.rb +0 -121
- data/lib/mindee/parsing/prediction/proof_of_address/proof_of_address_v1.rb +0 -80
- data/lib/mindee/parsing/prediction/receipt/receipt_v4.rb +0 -87
- data/lib/mindee/parsing/prediction/receipt/receipt_v5.rb +0 -136
- data/lib/mindee/parsing/prediction/receipt/receipt_v5_line_item.rb +0 -37
- data/lib/mindee/parsing/prediction/shipping_container/shipping_container_v1.rb +0 -38
- data/lib/mindee/parsing/prediction/us/bank_check/bank_check_v1.rb +0 -70
- data/lib/mindee/parsing/prediction.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c81762ec2e42847a182b6b864355ba0268ad22995c24b361e54fd5380f8191f3
|
4
|
+
data.tar.gz: 771736fbe9d28b5d7a91c7cfee9a687da116f176c8226f866ab8bf175cab7b7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 145a65bda997dc06a3ffafee6123d38195f66e6907c74097efca1a7d5bec9c8d70c041a7a58428e24be22a4850ff36e994a92024252735a815180032fe89f7a5
|
7
|
+
data.tar.gz: 605b1a9b1ffa2c0948581632eeca05e6462ce7f2280281740255183659648c7feb56ace62ec466cb69716f199a6a6467d4c5f1fa27e304fd83899b9a4dcfb2d9
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
1
|
# Mindee Ruby API Library Changelog
|
2
2
|
|
3
|
+
## v3.0.0 - 2023-06-29
|
4
|
+
### ¡Breaking Changes!
|
5
|
+
|
6
|
+
* :boom: update `Client` creation & document upload
|
7
|
+
* :boom: update custom `Endpoint` creation syntax
|
8
|
+
* :art: improve product class syntax & structure
|
9
|
+
* :recycle: harmonize naming with other client libraries
|
10
|
+
* :art: moved most parsing modules into their own respective modules
|
11
|
+
* :art: separated common, standard & custom parsing features into their own modules
|
12
|
+
|
13
|
+
### Changes
|
14
|
+
|
15
|
+
* :sparkles: add support for asynchronous endpoints
|
16
|
+
* :sparkles: add support for Invoice Splitter V1
|
17
|
+
* :sparkles: add support for OCR Full-text parsing on compatible APIs
|
18
|
+
* :sparkles: add support for FR Bank Account Details V2
|
19
|
+
* :sparkles: allow for the implementation of pages to differ from main document
|
20
|
+
* :sparkles: add url input source
|
21
|
+
* :coffin: remove Shipping Containers
|
22
|
+
* :recycle: moved all products into the `Product` module (from `Parsing`)
|
23
|
+
* :recycle: better implementation of geometric operations
|
24
|
+
* :pencil2: document all previously non-documented class
|
25
|
+
* :recycle: match file hierarchy with module nesting
|
26
|
+
* :recycle: rewrite tutorials to match new syntax
|
27
|
+
|
28
|
+
### Fixes
|
29
|
+
|
30
|
+
* :bug: fix: pages now use the proper `orientation` property
|
31
|
+
* :zap: optimize: only a single endpoint is now created on document upload
|
32
|
+
|
33
|
+
|
3
34
|
## v2.2.1 - 2023-05-22
|
4
35
|
### Fixes
|
5
36
|
* :bug: added base attribute to tax field
|
data/README.md
CHANGED
@@ -32,12 +32,15 @@ require 'mindee'
|
|
32
32
|
# Init a new client
|
33
33
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
34
34
|
|
35
|
-
# Load a file from disk
|
36
|
-
|
37
|
-
|
35
|
+
# Load a file from disk
|
36
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
37
|
+
result = mindee_client.parse(
|
38
|
+
input_source,
|
39
|
+
Mindee::Product::Invoice::InvoiceV4
|
40
|
+
)
|
38
41
|
|
39
42
|
# Print a full summary of the parsed data in RST format
|
40
|
-
puts result
|
43
|
+
puts result.document
|
41
44
|
```
|
42
45
|
|
43
46
|
#### Region-Specific Documents
|
@@ -47,12 +50,16 @@ require 'mindee'
|
|
47
50
|
# Init a new client
|
48
51
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
49
52
|
|
50
|
-
# Load a file from disk
|
51
|
-
|
52
|
-
|
53
|
+
# Load a file from disk
|
54
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
55
|
+
|
56
|
+
result = mindee_client.parse(
|
57
|
+
input_source,
|
58
|
+
Mindee::Product::EU::LicensePlate::LicensePlateV1
|
59
|
+
)
|
53
60
|
|
54
61
|
# Print a full summary of the parsed data in RST format
|
55
|
-
puts result
|
62
|
+
puts result.document
|
56
63
|
```
|
57
64
|
|
58
65
|
### Custom Document (API Builder)
|
@@ -60,20 +67,26 @@ puts result
|
|
60
67
|
require 'mindee'
|
61
68
|
|
62
69
|
# Init a new client and configure your custom document
|
63
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
64
|
-
|
65
|
-
'my-endpoint'
|
70
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
71
|
+
endpoint = mindee_client.create_endpoint(
|
72
|
+
endpoint_name: 'my-endpoint',
|
73
|
+
account_name: 'my-account'
|
66
74
|
)
|
67
75
|
|
68
|
-
# Load a file from disk
|
69
|
-
|
70
|
-
|
76
|
+
# Load a file from disk
|
77
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
78
|
+
|
79
|
+
result = mindee_client.parse(
|
80
|
+
input_source,
|
81
|
+
Mindee::Product::Custom::CustomV1,
|
82
|
+
endpoint: endpoint
|
83
|
+
)
|
71
84
|
|
72
85
|
# Print a full summary of the parsed data in RST format
|
73
|
-
puts result
|
86
|
+
puts result.document
|
74
87
|
|
75
88
|
# Looping over all prediction values
|
76
|
-
result.inference.prediction.fields.each do |field_name, field_data|
|
89
|
+
result.document.inference.prediction.fields.each do |field_name, field_data|
|
77
90
|
puts field_name
|
78
91
|
puts field_data.values
|
79
92
|
puts field_data.to_s
|
data/bin/mindee.rb
CHANGED
@@ -8,51 +8,51 @@ require 'mindee'
|
|
8
8
|
DOCUMENTS = {
|
9
9
|
"custom" => {
|
10
10
|
help: "Custom document type from API builder",
|
11
|
-
prediction: Mindee::
|
11
|
+
prediction: Mindee::Product::Custom::CustomV1,
|
12
12
|
},
|
13
13
|
"proof-of-address" => {
|
14
14
|
help: 'Proof of Address',
|
15
|
-
prediction: Mindee::
|
15
|
+
prediction: Mindee::Product::ProofOfAddress::ProofOfAddressV1,
|
16
16
|
},
|
17
17
|
"financial-document" => {
|
18
18
|
help: 'Financial Document',
|
19
|
-
prediction: Mindee::
|
19
|
+
prediction: Mindee::Product::FinancialDocument::FinancialDocumentV1,
|
20
20
|
},
|
21
21
|
"invoice" => {
|
22
22
|
help: 'Invoice',
|
23
|
-
prediction: Mindee::
|
23
|
+
prediction: Mindee::Product::Invoice::InvoiceV4,
|
24
24
|
},
|
25
25
|
"receipt" => {
|
26
26
|
help: "Expense Receipt",
|
27
|
-
prediction: Mindee::
|
27
|
+
prediction: Mindee::Product::Receipt::ReceiptV5,
|
28
28
|
},
|
29
29
|
"passport" => {
|
30
30
|
help: "Passport",
|
31
|
-
prediction: Mindee::
|
32
|
-
},
|
33
|
-
"shipping-container" => {
|
34
|
-
help: "Shipping Container",
|
35
|
-
prediction: Mindee::Prediction::ShippingContainerV1,
|
31
|
+
prediction: Mindee::Product::Passport::PassportV1,
|
36
32
|
},
|
37
33
|
"eu-license-plate" => {
|
38
34
|
help: "EU License Plate",
|
39
|
-
prediction: Mindee::
|
35
|
+
prediction: Mindee::Product::EU::LicensePlate::LicensePlateV1,
|
40
36
|
},
|
41
37
|
"fr-bank-account-details" => {
|
42
38
|
help: "FR Bank Account Details",
|
43
|
-
prediction: Mindee::
|
39
|
+
prediction: Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV1,
|
44
40
|
},
|
45
41
|
"fr-carte-vitale" => {
|
46
42
|
help: "FR Carte Vitale",
|
47
|
-
prediction: Mindee::
|
43
|
+
prediction: Mindee::Product::FR::CarteVitale::CarteVitaleV1,
|
48
44
|
},
|
49
45
|
"fr-id-card" => {
|
50
46
|
help: "FR ID Card",
|
51
|
-
prediction: Mindee::
|
47
|
+
prediction: Mindee::Product::FR::IdCard::IdCardV1,
|
52
48
|
},
|
53
49
|
"us-bank-check" => {
|
54
50
|
help: "US Bank Check",
|
55
|
-
prediction: Mindee::
|
51
|
+
prediction: Mindee::Product::US::BankCheck::BankCheckV1,
|
52
|
+
},
|
53
|
+
"invoice-splitter" => {
|
54
|
+
help: "US Bank Check",
|
55
|
+
prediction: Mindee::Product::InvoiceSplitter::InvoiceSplitterV1,
|
56
56
|
},
|
57
57
|
}
|
58
58
|
|
@@ -67,8 +67,8 @@ def ots_subcommand(command, options)
|
|
67
67
|
opt.on('-k [KEY]', '--key [KEY]', 'API key for the endpoint') do |v|
|
68
68
|
options[:api_key] = v
|
69
69
|
end
|
70
|
-
opt.on('-w', '--
|
71
|
-
options[:
|
70
|
+
opt.on('-w', '--all-words', 'Include words in response') do |v|
|
71
|
+
options[:all_words] = v
|
72
72
|
end
|
73
73
|
opt.on('-c', '--cut-pages', "Cut document pages") do |v|
|
74
74
|
options[:cut_pages] = v
|
@@ -79,8 +79,8 @@ end
|
|
79
79
|
def custom_subcommand(options)
|
80
80
|
OptionParser.new do |opt|
|
81
81
|
opt.banner = "Usage: custom [options] ENDPOINT_NAME FILE"
|
82
|
-
opt.on('-w', '--
|
83
|
-
options[:
|
82
|
+
opt.on('-w', '--all-words', 'Include words in response') do |v|
|
83
|
+
options[:all_words] = v
|
84
84
|
end
|
85
85
|
opt.on('-c', '--cut-pages', "Don't cut document pages") do |v|
|
86
86
|
options[:cut_pages] = v
|
@@ -127,9 +127,6 @@ if command == 'custom'
|
|
127
127
|
end
|
128
128
|
doc_type = ARGV[0]
|
129
129
|
file_path = ARGV[1]
|
130
|
-
mindee_client.add_endpoint(
|
131
|
-
options[:account_name], doc_type, version: options[:version] || '1',
|
132
|
-
)
|
133
130
|
else
|
134
131
|
if ARGV.length != 1
|
135
132
|
$stderr.puts 'No file specified.'
|
@@ -145,10 +142,10 @@ default_cutting = {
|
|
145
142
|
on_min_pages: 0,
|
146
143
|
}
|
147
144
|
page_options = options[:cut_pages].nil? ? nil : default_cutting
|
148
|
-
|
149
|
-
result =
|
145
|
+
input_source = mindee_client.source_from_path(file_path)
|
146
|
+
result = mindee_client.parse(input_source, DOCUMENTS[command][:prediction], page_options: page_options)
|
150
147
|
if options[:print_full]
|
151
|
-
puts result
|
148
|
+
puts result.document
|
152
149
|
else
|
153
|
-
puts result.inference.prediction
|
150
|
+
puts result.document.inference.prediction
|
154
151
|
end
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2
|
13
|
+
)
|
14
|
+
|
15
|
+
# Print a full summary of the parsed data in RST format
|
16
|
+
puts result.document
|
17
|
+
|
18
|
+
# Print the document-level parsed data
|
19
|
+
# puts result.document.inference.prediction
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::US::BankCheck::BankCheckV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::FR::CarteVitale::CarteVitaleV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -1,23 +1,32 @@
|
|
1
1
|
require 'mindee'
|
2
2
|
|
3
|
-
# Init a new client
|
4
|
-
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
-
|
6
|
-
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Initialize a custom endpoint for this product
|
10
|
+
custom_endpoint = mindee_client.create_endpoint(
|
11
|
+
account_name: 'my-account',
|
12
|
+
endpoint_name: 'my-endpoint'
|
7
13
|
)
|
8
14
|
|
9
|
-
#
|
10
|
-
result = mindee_client.
|
11
|
-
|
15
|
+
# Parse the file
|
16
|
+
result = mindee_client.parse(
|
17
|
+
input_source,
|
18
|
+
Mindee::Product::Custom::CustomV1,
|
19
|
+
endpoint: custom_endpoint
|
20
|
+
)
|
12
21
|
|
13
22
|
# Print a full summary of the parsed data in RST format
|
14
|
-
puts result
|
23
|
+
puts result.document
|
15
24
|
|
16
25
|
# Print the document-level parsed data
|
17
|
-
# puts result.inference.prediction
|
26
|
+
# puts result.document.inference.prediction
|
18
27
|
|
19
28
|
# Looping over all prediction values
|
20
|
-
result.inference.prediction.fields.each do |field_name, field_data|
|
29
|
+
result.document.inference.prediction.fields.each do |field_name, field_data|
|
21
30
|
puts field_name
|
22
31
|
puts field_data.values
|
23
32
|
puts field_data.to_s
|
@@ -2,15 +2,23 @@ require 'uri'
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'net/https'
|
4
4
|
|
5
|
-
|
5
|
+
api_key = "my-api-key"
|
6
|
+
account = "my-account"
|
7
|
+
endpoint = "my-endpoint"
|
8
|
+
version = "my-version"
|
9
|
+
|
10
|
+
url = URI("https://api.mindee.net/v1/products/#{account}/#{endpoint}/v#{version}/predict")
|
6
11
|
file = '/path/to/the/file.ext'
|
7
12
|
|
8
13
|
http = Net::HTTP.new(url.host, url.port)
|
9
14
|
http.use_ssl = true
|
10
15
|
|
11
16
|
request = Net::HTTP::Post.new(url)
|
12
|
-
request['Authorization'] =
|
17
|
+
request['Authorization'] = "Token #{api_key}"
|
13
18
|
request.set_form([['document', File.open(file)]], 'multipart/form-data')
|
14
19
|
|
15
20
|
response = http.request(request)
|
21
|
+
if !response.kind_of? Net::HTTPSuccess
|
22
|
+
raise response.msg
|
23
|
+
end
|
16
24
|
puts response.read_body
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::Receipt::ReceiptV4
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -1,14 +1,19 @@
|
|
1
1
|
require 'mindee'
|
2
2
|
|
3
|
-
# Init a new client
|
3
|
+
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::Receipt::ReceiptV5
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::FinancialDocument::FinancialDocumentV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::FR::IdCard::IdCardV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'mindee'
|
2
|
+
|
3
|
+
# Init a new client
|
4
|
+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
|
+
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Put the document class in a local variable to keep the code DRY
|
10
|
+
doc_class = Mindee::Product::InvoiceSplitter::InvoiceSplitterV1
|
11
|
+
|
12
|
+
# Limit the amount of API calls to retrieve your document
|
13
|
+
MAX_RETRIES = 10
|
14
|
+
|
15
|
+
# How many seconds to wait in-between tries
|
16
|
+
INTERVAL_SECS = 6
|
17
|
+
|
18
|
+
# Counter to keep track of how many times we try to retrieve the document
|
19
|
+
times_tried = 1
|
20
|
+
|
21
|
+
queue_result = mindee_client.enqueue(
|
22
|
+
input_source,
|
23
|
+
doc_class
|
24
|
+
)
|
25
|
+
|
26
|
+
# Get the id of the queue (job)
|
27
|
+
queue_id = queue_result.job.id
|
28
|
+
|
29
|
+
# Recursive function that tries to retrieve the completed document.
|
30
|
+
# If the document is not "complete", try again
|
31
|
+
def get_doc_from_async_queue(
|
32
|
+
queue_id,
|
33
|
+
mindee_client,
|
34
|
+
doc_class,
|
35
|
+
times_tried=0,
|
36
|
+
interval_secs=INTERVAL_SECS,
|
37
|
+
max_retries=MAX_RETRIES
|
38
|
+
)
|
39
|
+
# Have we exceeded our retry count?
|
40
|
+
if times_tried >= max_retries
|
41
|
+
raise "Maximum retries reached #{times_tried}"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Wait for a few seconds before fetching
|
45
|
+
sleep interval_secs
|
46
|
+
|
47
|
+
# Fetch and parse the result, using the same type
|
48
|
+
parsed_result = mindee_client.parse_queued(queue_id, doc_class)
|
49
|
+
|
50
|
+
# Check whether the result is ready
|
51
|
+
if parsed_result.job.status == Mindee::Parsing::Common::JobStatus::COMPLETED
|
52
|
+
# Print a brief summary of the parsed data
|
53
|
+
puts parsed_result.document
|
54
|
+
return
|
55
|
+
# Otherwise, try again...
|
56
|
+
else
|
57
|
+
get_doc_from_async_queue(
|
58
|
+
queue_id, mindee_client,
|
59
|
+
doc_class,
|
60
|
+
times_tried+1
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Start the recursion...
|
66
|
+
get_doc_from_async_queue(queue_id, mindee_client, doc_class)
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::Invoice::InvoiceV4
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::EU::LicensePlate::LicensePlateV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|
@@ -3,12 +3,17 @@ require 'mindee'
|
|
3
3
|
# Init a new client
|
4
4
|
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
|
5
5
|
|
6
|
-
# Load a file from disk
|
7
|
-
|
8
|
-
|
6
|
+
# Load a file from disk
|
7
|
+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
|
8
|
+
|
9
|
+
# Parse the file
|
10
|
+
result = mindee_client.parse(
|
11
|
+
input_source,
|
12
|
+
Mindee::Product::Passport::PassportV1
|
13
|
+
)
|
9
14
|
|
10
15
|
# Print a full summary of the parsed data in RST format
|
11
|
-
puts result
|
16
|
+
puts result.document
|
12
17
|
|
13
18
|
# Print the document-level parsed data
|
14
|
-
# puts result.inference.prediction
|
19
|
+
# puts result.document.inference.prediction
|