mindee 3.3.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +4 -0
  4. data/bin/mindee.rb +39 -15
  5. data/docs/bank_statement_fr_v1.md +175 -0
  6. data/docs/carte_grise_v1.md +4 -4
  7. data/docs/code_samples/bank_statement_fr_v1_async.txt +19 -0
  8. data/docs/code_samples/default.txt +19 -19
  9. data/docs/code_samples/default_async.txt +25 -0
  10. data/docs/code_samples/eu_driver_license_v1.txt +19 -0
  11. data/docs/code_samples/international_id_v1_async.txt +19 -0
  12. data/docs/code_samples/international_id_v2_async.txt +19 -0
  13. data/docs/eu_driver_license_v1.md +223 -0
  14. data/docs/financial_document_v1.md +48 -40
  15. data/docs/generated_v1.md +90 -0
  16. data/docs/invoices_v4.md +13 -4
  17. data/docs/proof_of_address_v1.md +4 -4
  18. data/docs/us_driver_license_v1.md +2 -2
  19. data/lib/mindee/client.rb +5 -3
  20. data/lib/mindee/http/endpoint.rb +13 -12
  21. data/lib/mindee/input/sources.rb +28 -5
  22. data/lib/mindee/parsing/common/inference.rb +3 -1
  23. data/lib/mindee/parsing/generated/generated_list_field.rb +58 -0
  24. data/lib/mindee/parsing/generated/generated_object_field.rb +109 -0
  25. data/lib/mindee/parsing/generated.rb +4 -0
  26. data/lib/mindee/parsing/standard/string_field.rb +8 -0
  27. data/lib/mindee/parsing.rb +1 -0
  28. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +3 -1
  29. data/lib/mindee/product/cropper/cropper_v1.rb +3 -1
  30. data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +41 -0
  31. data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +88 -0
  32. data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +53 -0
  33. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +3 -1
  34. data/lib/mindee/product/financial_document/financial_document_v1.rb +3 -1
  35. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +3 -1
  36. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +3 -1
  37. data/lib/mindee/product/fr/bank_statement/bank_statement_v1.rb +41 -0
  38. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_document.rb +130 -0
  39. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb +34 -0
  40. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_transaction.rb +64 -0
  41. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +3 -1
  42. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +3 -1
  43. data/lib/mindee/product/fr/id_card/id_card_v1.rb +3 -1
  44. data/lib/mindee/product/fr/id_card/id_card_v2.rb +3 -1
  45. data/lib/mindee/product/generated/generated_v1.rb +38 -0
  46. data/lib/mindee/product/generated/generated_v1_document.rb +35 -0
  47. data/lib/mindee/product/generated/generated_v1_page.rb +51 -0
  48. data/lib/mindee/product/generated/generated_v1_prediction.rb +114 -0
  49. data/lib/mindee/product/international_id/international_id_v1.rb +39 -0
  50. data/lib/mindee/product/international_id/international_id_v1_document.rb +109 -0
  51. data/lib/mindee/product/international_id/international_id_v1_page.rb +32 -0
  52. data/lib/mindee/product/international_id/international_id_v2.rb +39 -0
  53. data/lib/mindee/product/international_id/international_id_v2_document.rb +119 -0
  54. data/lib/mindee/product/international_id/international_id_v2_page.rb +32 -0
  55. data/lib/mindee/product/invoice/invoice_v4.rb +3 -1
  56. data/lib/mindee/product/invoice/invoice_v4_document.rb +5 -0
  57. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +3 -1
  58. data/lib/mindee/product/passport/passport_v1.rb +3 -1
  59. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +3 -1
  60. data/lib/mindee/product/receipt/receipt_v5.rb +3 -1
  61. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +3 -1
  62. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +3 -1
  63. data/lib/mindee/product/us/w9/w9_v1.rb +3 -1
  64. data/lib/mindee/product.rb +5 -0
  65. data/lib/mindee/version.rb +1 -1
  66. data/lib/mindee.rb +4 -0
  67. metadata +30 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c6039978a362b6a5faab3b92fb4ef24fd9cbf85060f66614b007b371d851843
4
- data.tar.gz: 4aa9ef461ee5fcc19f483dde6f584c583390e53ebba1889d5283b1864a26169c
3
+ metadata.gz: d3711d1d33d9aeb118b9c891443d0e2ecf4973db242797f15d7628f3a157c0f8
4
+ data.tar.gz: b63e5dfd3a85fb3b234b0ae6d0afd8b1b2386eba3a2977788298e2cbf7ce79c9
5
5
  SHA512:
6
- metadata.gz: 226aa7601ad8b1a80dc6fb1071ad655a9aae647d70118184d0ada431b314503eb3f6157abdc59eb0205e157c3d7d8cc501ceb26258690ed9ad038b4d41336f93
7
- data.tar.gz: a1d215cb0834ded50c9bcb913d2cf074d7e711ec73aaa67380705c71d51e29b6c15a162fa7afcadcab027954831155fdf065563cee1ce2aa0a7b300359cd7421
6
+ metadata.gz: 3ec2c83d25ca5e1cd72cc1045a5a6ed8f299dbdf3de2729344eac833a37351dd16a71d14b73679b441b7263e2992a577c618b3143484c8bfac262fd41697fbe5
7
+ data.tar.gz: 2de29dd3f708a25ef53e2c61aa86f40684d8ae2aac6cd875e931cd1e0cc0ed8e972439e75c8731e570b7fd7aa1a3884f5c341afe2a29fef40a37bc542ae60c15
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Mindee Ruby API Library Changelog
2
2
 
3
+ ## v3.5.0 - 2024-02-16
4
+ ### Changes
5
+ * :sparkles: add support for Generated V1 API
6
+ * :recycle: documents now aren't automatically converted to b64 when enqueued as non-PDF files
7
+ * :recycle: increase max async delay to 60 tries
8
+ * :sparkles: add support for FR bank statements
9
+ * :sparkles: add support for International ID V2
10
+ * :sparkles: add support for EU Driver License V1
11
+ * :recycle: update existing products
12
+ * :arrow_up: upgrade test lib
13
+
14
+ ### Fixes
15
+ * :memo: add missing default async sample code
16
+ * :bug: fix rst display issues
17
+ * :bug: fix display issues for single page models
18
+ * :bug: fix miscellaneous issues related to data display (no changes expected on existing models)
19
+ * :bug: fix CLI breaking for custom products
20
+ * :bug: fix encoding issue that prevented UNICODE file names from being properly sent to the server
21
+
22
+
23
+ ## v3.4.0 - 2024-01-30
24
+ ### Changes
25
+ * :arrow_up: update invoices to v4.4
26
+ * :sparkles: add support for `raw_value` in string fields
27
+
28
+
3
29
  ## v3.3.1 - 2023-12-15
4
30
  ### Changes
5
31
  * :recycle: tweak async delays & retry
data/README.md CHANGED
@@ -135,13 +135,17 @@ customize the experience.
135
135
 
136
136
  * [Ruby Overview](https://developers.mindee.com/docs/getting-started-ocr-ruby)
137
137
  * [Custom OCR Ruby](https://developers.mindee.com/docs/api-builder-ocr-ruby)
138
+ * [Generated API Ruby](https://developers.mindee.com/docs/generated-api-ruby)
138
139
  * [Invoice OCR Ruby](https://developers.mindee.com/docs/invoice-ocr-ruby)
140
+ * [International Id OCR Ruby](https://developers.mindee.com/docs/international-id-ocr-ruby)
139
141
  * [Financial Document OCR Ruby](https://developers.mindee.com/docs/financial-document-ocr-ruby)
140
142
  * [Passport OCR Ruby](https://developers.mindee.com/docs/passport-ocr-ruby)
141
143
  * [Proof of Address OCR Ruby](https://developers.mindee.com/docs/proof-of-address-ocr-ruby)
142
144
  * [Receipt OCR Ruby](https://developers.mindee.com/docs/receipt-ocr-ruby)
143
145
  * [EU License Plate OCR Ruby](https://developers.mindee.com/docs/eu-license-plate-ocr-ruby)
146
+ * [EU Driver License OCR Ruby](https://developers.mindee.com/docs/eu-driver-license-ocr-ruby)
144
147
  * [FR Bank Account Details OCR Ruby](https://developers.mindee.com/docs/fr-bank-account-details-ocr-ruby)
148
+ * [FR Bank Statement OCR Ruby](https://developers.mindee.com/docs/fr-bank-statement-ocr-ruby)
145
149
  * [FR Carte Vitale OCR Ruby](https://developers.mindee.com/docs/fr-carte-vitale-ocr-ruby)
146
150
  * [FR ID Card OCR Ruby](https://developers.mindee.com/docs/fr-id-card-ocr-ruby)
147
151
  * [US Bank Check OCR Ruby](https://developers.mindee.com/docs/us-bank-check-ocr-ruby)
data/bin/mindee.rb CHANGED
@@ -5,6 +5,7 @@ require 'bundler/setup'
5
5
  require 'optparse'
6
6
  require 'mindee'
7
7
 
8
+ options = {}
8
9
  DOCUMENTS = {
9
10
  "custom" => {
10
11
  description: "Custom document type from API builder",
@@ -12,6 +13,12 @@ DOCUMENTS = {
12
13
  sync: true,
13
14
  async: false,
14
15
  },
16
+ "generated" => {
17
+ description: "Generated document type from API builder",
18
+ doc_class: Mindee::Product::Generated::GeneratedV1,
19
+ sync: true,
20
+ async: true,
21
+ },
15
22
  "proof-of-address" => {
16
23
  description: 'Proof of Address',
17
24
  doc_class: Mindee::Product::ProofOfAddress::ProofOfAddressV1,
@@ -36,6 +43,12 @@ DOCUMENTS = {
36
43
  sync: true,
37
44
  async: false,
38
45
  },
46
+ "international-id" => {
47
+ description: 'International Id',
48
+ doc_class: Mindee::Product::InternationalId::InternationalIdV2,
49
+ sync: false,
50
+ async: true,
51
+ },
39
52
  "receipt" => {
40
53
  description: "Expense Receipt",
41
54
  doc_class: Mindee::Product::Receipt::ReceiptV5,
@@ -54,12 +67,24 @@ DOCUMENTS = {
54
67
  sync: true,
55
68
  async: false,
56
69
  },
70
+ "eu-driver-license" => {
71
+ description: "EU Driver License",
72
+ doc_class: Mindee::Product::EU::DriverLicense::DriverLicenseV1,
73
+ sync: true,
74
+ async: false,
75
+ },
57
76
  "fr-bank-account-details" => {
58
77
  description: "FR Bank Account Details",
59
78
  doc_class: Mindee::Product::FR::BankAccountDetails::BankAccountDetailsV2,
60
79
  sync: true,
61
80
  async: false,
62
81
  },
82
+ "fr-bank-statement" => {
83
+ description: "FR Bank Statement",
84
+ doc_class: Mindee::Product::FR::BankStatement::BankStatementV1,
85
+ sync: false,
86
+ async: true,
87
+ },
63
88
  "fr-carte-vitale" => {
64
89
  description: "FR Carte Vitale",
65
90
  doc_class: Mindee::Product::FR::CarteVitale::CarteVitaleV1,
@@ -105,11 +130,11 @@ DEFAULT_CUTTING = {
105
130
  on_min_pages: 0,
106
131
  }
107
132
 
108
- # Initializes custom-specific options
133
+ # Initializes custom & generated-specific options
109
134
  # @param cli_parser [OptionParser]
110
- def custom_subcommand(cli_parser)
135
+ def custom_subcommand(cli_parser, options)
111
136
  cli_parser.on('-v [VERSION]', '--version [VERSION]', 'Model version for the API') do |v|
112
- options[:version] = v
137
+ options[:endpoint_version] = v
113
138
  end
114
139
  cli_parser.on('-a ACCOUNT_NAME', '--account ACCOUNT_NAME', 'API account name for the endpoint') do |v|
115
140
  options[:account_name] = v
@@ -118,7 +143,7 @@ end
118
143
 
119
144
  product_parser = {}
120
145
  DOCUMENTS.each do |doc_key, doc_value|
121
- product_parser[doc_key] = OptionParser.new do | opts |
146
+ product_parser[doc_key] = OptionParser.new do |opts|
122
147
  opts.on('-w', '--all-words', 'Include words in response') do |v|
123
148
  options[:all_words] = v
124
149
  end
@@ -134,11 +159,11 @@ DOCUMENTS.each do |doc_key, doc_value|
134
159
  opts.on('-F', '--fix-pdf', "Attempts to fix broken PDF files before sending them to the server.") do |v|
135
160
  options[:fix_pdf] = true
136
161
  end
137
- if (doc_key != 'custom')
162
+ if (doc_key != 'custom' && doc_key != 'generated')
138
163
  opts.banner = "Product: #{doc_value[:description]}. \nUsage: mindee.rb #{doc_key} [options] file"
139
164
  else
140
- opts.banner = "#{doc_value[:description]}. \nUsage: mindee.rb custom [options] endpoint_name file"
141
- custom_subcommand(opts)
165
+ opts.banner = "#{doc_value[:description]}. \nUsage: \nmindee.rb custom [options] endpoint_name file\nor\nmindee.rb generated [options] endpoint_name file"
166
+ custom_subcommand(opts, options)
142
167
  end
143
168
  if doc_value[:async]
144
169
  if doc_value[:sync]
@@ -150,7 +175,7 @@ DOCUMENTS.each do |doc_key, doc_value|
150
175
  end
151
176
  end
152
177
 
153
- global_parser = OptionParser.new do | opts |
178
+ global_parser = OptionParser.new do |opts|
154
179
  opts.banner = "Usage: mindee.rb product [options] file"
155
180
  opts.separator "Available products:"
156
181
  opts.separator " #{DOCUMENTS.keys.join("\n ")}"
@@ -163,9 +188,9 @@ end
163
188
  doc_class = DOCUMENTS[command][:doc_class]
164
189
  product_parser[command].parse!
165
190
 
166
- if command == 'custom'
191
+ if command == 'custom' || command == 'generated'
167
192
  if ARGV.length < 2
168
- $stderr.puts "The 'custom' command requires both ENDPOINT_NAME and file arguments."
193
+ $stderr.puts "The '#{command}' command requires both ENDPOINT_NAME and file arguments."
169
194
  abort(product_parser[command].help)
170
195
  end
171
196
  endpoint_name = ARGV[0]
@@ -186,12 +211,11 @@ else
186
211
  input_source = mindee_client.source_from_path(options[:file_path], fix_pdf: options[:fix_pdf])
187
212
  end
188
213
 
189
- if command == 'custom'
190
- endpoint_name = 'endpoint_name'
214
+ if command == 'custom' || command == 'generated'
191
215
  custom_endpoint = mindee_client.create_endpoint(
192
- account_name: endpoint_name,
193
- endpoint_name: options[:account_name],
194
- endpoint_version: options[:endpoint_version].nil? ? "1" : options[:endpoint_version]
216
+ endpoint_name: endpoint_name,
217
+ account_name: options[:account_name],
218
+ version: options[:endpoint_version].nil? ? "1" : options[:endpoint_version]
195
219
  )
196
220
  else
197
221
  custom_endpoint = nil
@@ -0,0 +1,175 @@
1
+ ---
2
+ title: FR Bank Statement (FR) OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Bank Statement (FR) API](https://platform.mindee.com/mindee/bank_statement_fr).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_statement_fr/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Bank Statement (FR) sample](https://github.com/mindee/client-lib-test-data/blob/main/products/bank_statement_fr/default_sample.jpg?raw=true)
8
+
9
+ # Quick-Start
10
+ ```rb
11
+ require 'mindee'
12
+
13
+ # Init a new client
14
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
15
+
16
+ # Load a file from disk
17
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
18
+
19
+ # Parse the file
20
+ result = mindee_client.enqueue_and_parse(
21
+ input_source,
22
+ Mindee::Product::FR::BankStatement::BankStatementV1
23
+ )
24
+
25
+ # Print a full summary of the parsed data in RST format
26
+ puts result.document
27
+
28
+ # Print the document-level parsed data
29
+ # puts result.document.inference.prediction
30
+ ```
31
+
32
+ **Output (RST):**
33
+ ```rst
34
+ ```
35
+
36
+ # Field Types
37
+ ## Standard Fields
38
+ These fields are generic and used in several products.
39
+
40
+ ### Basic Field
41
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
42
+ A typical `Field` object will have the following attributes:
43
+
44
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
45
+ * **confidence** (Float, nil): the confidence score of the field prediction.
46
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
47
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
48
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
49
+ * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
50
+
51
+
52
+ Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string.
53
+
54
+
55
+ ### Amount Field
56
+ The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
57
+
58
+ ### Date Field
59
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
60
+
61
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
62
+
63
+ ### String Field
64
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
65
+
66
+ ## Specific Fields
67
+ Fields which are specific to this product; they are not used in any other product.
68
+
69
+ ### Transactions Field
70
+ The list of values that represent the financial transactions recorded in a bank statement.
71
+
72
+ A `BankStatementV1Transaction` implements the following attributes:
73
+
74
+ * `amount` (Float): The monetary amount of the transaction.
75
+ * `date` (String): The date on which the transaction occurred.
76
+ * `description` (String): The additional information about the transaction.
77
+
78
+ # Attributes
79
+ The following fields are extracted for Bank Statement (FR) V1:
80
+
81
+ ## Account Number
82
+ **account_number** ([StringField](#string-field)): The unique identifier for a customer's account in the bank's system.
83
+
84
+ ```rb
85
+ puts result.document.inference.prediction.account_number.value
86
+ ```
87
+
88
+ ## Bank Address
89
+ **bank_address** ([StringField](#string-field)): The physical location of the bank where the statement was issued.
90
+
91
+ ```rb
92
+ puts result.document.inference.prediction.bank_address.value
93
+ ```
94
+
95
+ ## Bank Name
96
+ **bank_name** ([StringField](#string-field)): The name of the bank that issued the statement.
97
+
98
+ ```rb
99
+ puts result.document.inference.prediction.bank_name.value
100
+ ```
101
+
102
+ ## Client Address
103
+ **client_address** ([StringField](#string-field)): The address of the client associated with the bank statement.
104
+
105
+ ```rb
106
+ puts result.document.inference.prediction.client_address.value
107
+ ```
108
+
109
+ ## Client Name
110
+ **client_name** ([StringField](#string-field)): The name of the client who owns the bank statement.
111
+
112
+ ```rb
113
+ puts result.document.inference.prediction.client_name.value
114
+ ```
115
+
116
+ ## Closing Balance
117
+ **closing_balance** ([AmountField](#amount-field)): The final amount of money in the account at the end of the statement period.
118
+
119
+ ```rb
120
+ puts result.document.inference.prediction.closing_balance.value
121
+ ```
122
+
123
+ ## Opening Balance
124
+ **opening_balance** ([AmountField](#amount-field)): The initial amount of money in an account at the start of the period.
125
+
126
+ ```rb
127
+ puts result.document.inference.prediction.opening_balance.value
128
+ ```
129
+
130
+ ## Statement Date
131
+ **statement_date** ([DateField](#date-field)): The date on which the bank statement was generated.
132
+
133
+ ```rb
134
+ puts result.document.inference.prediction.statement_date.value
135
+ ```
136
+
137
+ ## Statement End Date
138
+ **statement_end_date** ([DateField](#date-field)): The date when the statement period ends.
139
+
140
+ ```rb
141
+ puts result.document.inference.prediction.statement_end_date.value
142
+ ```
143
+
144
+ ## Statement Start Date
145
+ **statement_start_date** ([DateField](#date-field)): The date when the bank statement period begins.
146
+
147
+ ```rb
148
+ puts result.document.inference.prediction.statement_start_date.value
149
+ ```
150
+
151
+ ## Total Credits
152
+ **total_credits** ([AmountField](#amount-field)): The total amount of money deposited into the account.
153
+
154
+ ```rb
155
+ puts result.document.inference.prediction.total_credits.value
156
+ ```
157
+
158
+ ## Total Debits
159
+ **total_debits** ([AmountField](#amount-field)): The total amount of money debited from the account.
160
+
161
+ ```rb
162
+ puts result.document.inference.prediction.total_debits.value
163
+ ```
164
+
165
+ ## Transactions
166
+ **transactions** (Array<[BankStatementV1Transaction](#transactions-field)>): The list of values that represent the financial transactions recorded in a bank statement.
167
+
168
+ ```rb
169
+ for transactions_elem in result.document.inference.prediction.transactions do
170
+ puts transactions_elem.value
171
+ end
172
+ ```
173
+
174
+ # Questions?
175
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
@@ -34,12 +34,12 @@ puts result.document
34
34
  ########
35
35
  Document
36
36
  ########
37
- :Mindee ID: f0e0f7a9-0f44-4a3d-92c7-5be262133d33
37
+ :Mindee ID: 4443182b-57c1-4426-a288-01b94f226e84
38
38
  :Filename: default_sample.jpg
39
39
 
40
40
  Inference
41
41
  #########
42
- :Product: mindee/carte_grise v1.0
42
+ :Product: mindee/carte_grise v1.1
43
43
  :Rotation applied: Yes
44
44
 
45
45
  Prediction
@@ -67,14 +67,14 @@ Prediction
67
67
  :p2: 90
68
68
  :p3: GO
69
69
  :p6: 6
70
- :q:
70
+ :q: 006
71
71
  :s1: 5
72
72
  :s2:
73
73
  :u1: 77
74
74
  :u2: 3000
75
75
  :v7: 155
76
76
  :x1: 2011-07-06
77
- :y1:
77
+ :y1: 17835
78
78
  :y2:
79
79
  :y3: 0
80
80
  :y4: 4
@@ -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.enqueue_and_parse(
11
+ input_source,
12
+ Mindee::Product::FR::BankStatement::BankStatementV1
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
@@ -1,24 +1,24 @@
1
- require 'uri'
2
- require 'net/http'
3
- require 'net/https'
1
+ require 'mindee'
4
2
 
5
- api_key = "my-api-key"
6
- account = "my-account"
7
- endpoint = "my-endpoint"
8
- version = "my-version"
3
+ # Init a new client
4
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
9
5
 
10
- url = URI("https://api.mindee.net/v1/products/#{account}/#{endpoint}/v#{version}/predict")
11
- file = '/path/to/the/file.ext'
6
+ # Load a file from disk
7
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
12
8
 
13
- http = Net::HTTP.new(url.host, url.port)
14
- http.use_ssl = true
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',
13
+ version: 'my-version'
14
+ )
15
15
 
16
- request = Net::HTTP::Post.new(url)
17
- request['Authorization'] = "Token #{api_key}"
18
- request.set_form([['document', File.open(file)]], 'multipart/form-data')
16
+ # Parse the file
17
+ result = mindee_client.parse(
18
+ input_source,
19
+ Mindee::Product::Generated::GeneratedV1,
20
+ endpoint: custom_endpoint
21
+ )
19
22
 
20
- response = http.request(request)
21
- if !response.kind_of? Net::HTTPSuccess
22
- raise response.msg
23
- end
24
- puts response.read_body
23
+ # Print a full summary of the parsed data in RST format
24
+ puts result.document
@@ -0,0 +1,25 @@
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
+ # Initialize a custom endpoint for this product
10
+ custom_endpoint = mindee_client.create_endpoint(
11
+ account_name: 'my-account',
12
+ endpoint_name: 'my-endpoint',
13
+ version: 'my-version'
14
+ )
15
+
16
+ # Parse the file
17
+ result = mindee_client.enqueue_and_parse(
18
+ input_source,
19
+ Mindee::Product::Generated::GeneratedV1,
20
+ endpoint: custom_endpoint
21
+ )
22
+
23
+ # Print a full summary of the parsed data in RST format
24
+ puts result.document
25
+
@@ -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::EU::DriverLicense::DriverLicenseV1
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
@@ -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.enqueue_and_parse(
11
+ input_source,
12
+ Mindee::Product::InternationalId::InternationalIdV1
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
@@ -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.enqueue_and_parse(
11
+ input_source,
12
+ Mindee::Product::InternationalId::InternationalIdV2
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