mindee 4.7.1 → 4.8.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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +6 -6
  4. data/Rakefile +1 -0
  5. data/lib/mindee/errors/mindee_http_error_v2.rb +23 -4
  6. data/lib/mindee/errors/mindee_http_unknown_error_v2.rb +18 -0
  7. data/lib/mindee/http/endpoint.rb +1 -0
  8. data/lib/mindee/input/sources/local_input_source.rb +9 -1
  9. data/lib/mindee/parsing/v2/error_item.rb +21 -0
  10. data/lib/mindee/parsing/v2/error_response.rb +18 -3
  11. data/lib/mindee/parsing/v2/inference_result.rb +4 -0
  12. data/lib/mindee/parsing/v2/rag_metadata.rb +17 -0
  13. data/lib/mindee/product.rb +0 -1
  14. data/lib/mindee/version.rb +1 -1
  15. data/mindee.gemspec +1 -0
  16. data/sig/mindee/errors/mindee_http_error_v2.rbs +4 -1
  17. data/sig/mindee/errors/mindee_http_unknown_error_v2.rbs +9 -0
  18. data/sig/mindee/http/endpoint.rbs +1 -0
  19. data/sig/mindee/input/sources/local_input_source.rbs +1 -1
  20. data/sig/mindee/parsing/v2/error_item.rbs +13 -0
  21. data/sig/mindee/parsing/v2/error_response.rbs +3 -0
  22. data/sig/mindee/parsing/v2/inference_result.rbs +1 -0
  23. data/sig/mindee/parsing/v2/rag_metadata.rbs +13 -0
  24. metadata +22 -47
  25. data/docs/advanced_file_operations.md +0 -109
  26. data/docs/code_samples/us_mail_v2_async.txt +0 -24
  27. data/docs/getting_started.md +0 -257
  28. data/docs/global_products/barcode_reader_v1.md +0 -125
  29. data/docs/global_products/bill_of_lading_v1.md +0 -276
  30. data/docs/global_products/business_card_v1.md +0 -194
  31. data/docs/global_products/cropper_v1.md +0 -123
  32. data/docs/global_products/delivery_notes_v1.md +0 -168
  33. data/docs/global_products/driver_license_v1.md +0 -212
  34. data/docs/global_products/expense_receipts_v5.md +0 -415
  35. data/docs/global_products/financial_document_v1.md +0 -615
  36. data/docs/global_products/international_id_v2.md +0 -264
  37. data/docs/global_products/invoice_splitter_v1.md +0 -127
  38. data/docs/global_products/invoices_v4.md +0 -576
  39. data/docs/global_products/multi_receipts_detector_v1.md +0 -131
  40. data/docs/global_products/nutrition_facts_v1.md +0 -399
  41. data/docs/global_products/passport_v1.md +0 -207
  42. data/docs/global_products/resume_v1.md +0 -384
  43. data/docs/global_products/universal.md +0 -113
  44. data/docs/global_products.md +0 -6
  45. data/docs/loading_a_document.md +0 -330
  46. data/docs/localized_products/bank_account_details_v2.md +0 -158
  47. data/docs/localized_products/bank_check_v1.md +0 -205
  48. data/docs/localized_products/bank_statement_fr_v2.md +0 -269
  49. data/docs/localized_products/carte_grise_v1.md +0 -475
  50. data/docs/localized_products/energy_bill_fra_v1.md +0 -342
  51. data/docs/localized_products/french_healthcard_v1.md +0 -142
  52. data/docs/localized_products/idcard_fr_v2.md +0 -284
  53. data/docs/localized_products/ind_passport_v1.md +0 -307
  54. data/docs/localized_products/payslip_fra_v3.md +0 -344
  55. data/docs/localized_products/us_healthcare_cards_v1.md +0 -258
  56. data/docs/localized_products/us_mail_v3.md +0 -152
  57. data/docs/localized_products.md +0 -6
  58. data/lib/mindee/product/us/us_mail/us_mail_v2.rb +0 -47
  59. data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +0 -105
  60. data/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +0 -38
  61. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +0 -105
  62. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +0 -63
  63. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +0 -66
  64. data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +0 -13
  65. data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +0 -20
  66. data/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs +0 -17
  67. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +0 -22
  68. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +0 -15
  69. data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +0 -18
@@ -1,576 +0,0 @@
1
- ---
2
- title: Invoice
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-invoice-ocr
5
- parentDoc: 67b49df15b843f3fa9cd622b
6
- ---
7
- The Ruby Client Library supports the [Invoice API](https://platform.mindee.com/mindee/invoices).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `invoices` |
15
- > | Recommended Version | `v4.11` |
16
- > | Supports Polling/Webhooks | ✔️ Yes |
17
- > | Support Synchronous HTTP Calls | ✔️ Yes |
18
- > | Geography | 🌐 Global |
19
-
20
- > 🔐 Polling Limitations
21
- >
22
- > | Setting | Parameter name | Default Value |
23
- > | ------------------------------- | ----------------------- | ------------- |
24
- > | Initial Delay Before Polling | `initial_delay_seconds` | 2 seconds |
25
- > | Default Delay Between Calls | `delay_sec` | 1.5 seconds |
26
- > | Polling Attempts Before Timeout | `max_retries` | 80 retries |
27
-
28
-
29
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/invoices/default_sample.jpg),
30
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
31
- ![Invoice sample](https://github.com/mindee/client-lib-test-data/blob/main/products/invoices/default_sample.jpg?raw=true)
32
-
33
- # Quick-Start
34
- ```rb
35
- #
36
- # Install the Ruby client library by running:
37
- # gem install mindee
38
- #
39
-
40
- require 'mindee'
41
-
42
- # Init a new client
43
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
44
-
45
- # Load a file from disk
46
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
47
-
48
- # Parse the file
49
- result = mindee_client.parse(
50
- input_source,
51
- Mindee::Product::Invoice::InvoiceV4,
52
- enqueue: false
53
- )
54
-
55
- # Print a full summary of the parsed data in RST format
56
- puts result.document
57
-
58
- # Print the document-level parsed data
59
- # puts result.document.inference.prediction
60
- ```
61
-
62
- You can also call this product asynchronously:
63
-
64
- ```rb
65
- #
66
- # Install the Ruby client library by running:
67
- # gem install mindee
68
- #
69
-
70
- require 'mindee'
71
-
72
- # Init a new client
73
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
74
-
75
- # Load a file from disk
76
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
77
-
78
- # Parse the file
79
- result = mindee_client.parse(
80
- input_source,
81
- Mindee::Product::Invoice::InvoiceV4
82
- )
83
-
84
- # Print a full summary of the parsed data in RST format
85
- puts result.document
86
-
87
- # Print the document-level parsed data
88
- # puts result.document.inference.prediction
89
- ```
90
-
91
- **Output (RST):**
92
- ```rst
93
- ########
94
- Document
95
- ########
96
- :Mindee ID: 744748d5-9051-461c-b70c-bbf81f5ff943
97
- :Filename: default_sample.jpg
98
-
99
- Inference
100
- #########
101
- :Product: mindee/invoices v4.11
102
- :Rotation applied: Yes
103
-
104
- Prediction
105
- ==========
106
- :Locale: en-CA; en; CA; CAD;
107
- :Invoice Number: 14
108
- :Purchase Order Number: AD29094
109
- :Reference Numbers: AD29094
110
- :Purchase Date: 2018-09-25
111
- :Due Date:
112
- :Payment Date:
113
- :Total Net: 2145.00
114
- :Total Amount: 2608.20
115
- :Total Tax: 193.20
116
- :Taxes:
117
- +---------------+--------+----------+---------------+
118
- | Base | Code | Rate (%) | Amount |
119
- +===============+========+==========+===============+
120
- | 2145.00 | | 8.00 | 193.20 |
121
- +---------------+--------+----------+---------------+
122
- :Supplier Payment Details:
123
- :Supplier Name: TURNPIKE DESIGNS
124
- :Supplier Company Registrations:
125
- :Supplier Address: 156 University Ave, Toronto ON, Canada, M5H 2H7
126
- :Supplier Phone Number: 4165551212
127
- :Supplier Website:
128
- :Supplier Email: j_coi@example.com
129
- :Customer Name: JIRO DOI
130
- :Customer Company Registrations:
131
- :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
132
- :Customer ID:
133
- :Shipping Address:
134
- :Billing Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
135
- :Document Type: INVOICE
136
- :Document Type Extended: INVOICE
137
- :Purchase Subcategory:
138
- :Purchase Category: miscellaneous
139
- :Line Items:
140
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
141
- | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit of measure | Unit Price |
142
- +======================================+==============+==========+============+==============+==============+=================+============+
143
- | Platinum web hosting package Down... | | 1.00 | | | 65.00 | | 65.00 |
144
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
145
- | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | | 2100.00 |
146
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
147
- | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 1 | 250.00 |
148
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
149
-
150
- Page Predictions
151
- ================
152
-
153
- Page 0
154
- ------
155
- :Locale: en-CA; en; CA; CAD;
156
- :Invoice Number: 14
157
- :Purchase Order Number: AD29094
158
- :Reference Numbers: AD29094
159
- :Purchase Date: 2018-09-25
160
- :Due Date:
161
- :Payment Date:
162
- :Total Net: 2145.00
163
- :Total Amount: 2608.20
164
- :Total Tax: 193.20
165
- :Taxes:
166
- +---------------+--------+----------+---------------+
167
- | Base | Code | Rate (%) | Amount |
168
- +===============+========+==========+===============+
169
- | 2145.00 | | 8.00 | 193.20 |
170
- +---------------+--------+----------+---------------+
171
- :Supplier Payment Details:
172
- :Supplier Name: TURNPIKE DESIGNS
173
- :Supplier Company Registrations:
174
- :Supplier Address: 156 University Ave, Toronto ON, Canada, M5H 2H7
175
- :Supplier Phone Number: 4165551212
176
- :Supplier Website:
177
- :Supplier Email: j_coi@example.com
178
- :Customer Name: JIRO DOI
179
- :Customer Company Registrations:
180
- :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
181
- :Customer ID:
182
- :Shipping Address:
183
- :Billing Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
184
- :Document Type: INVOICE
185
- :Document Type Extended: INVOICE
186
- :Purchase Subcategory:
187
- :Purchase Category: miscellaneous
188
- :Line Items:
189
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
190
- | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit of measure | Unit Price |
191
- +======================================+==============+==========+============+==============+==============+=================+============+
192
- | Platinum web hosting package Down... | | 1.00 | | | 65.00 | | 65.00 |
193
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
194
- | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | | 2100.00 |
195
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
196
- | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 1 | 250.00 |
197
- +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
198
- ```
199
-
200
- # Field Types
201
- ## Standard Fields
202
- These fields are generic and used in several products.
203
-
204
- ### Basic Field
205
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
206
- A typical `Field` object will have the following attributes:
207
-
208
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
209
- * **confidence** (Float, nil): the confidence score of the field prediction.
210
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
211
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
212
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
213
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
214
-
215
-
216
- 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.
217
-
218
-
219
- ### AddressField
220
- Aside from the basic `BaseField` attributes, the address field `AddressField` also implements the following:
221
-
222
- * **street_number** (`String`): String representation of the street number. Can be `nil`.
223
- * **street_name** (`String`): Name of the street. Can be `nil`.
224
- * **po_box** (`String`): String representation of the PO Box number. Can be `nil`.
225
- * **address_complement** (`String`): Address complement. Can be `nil`.
226
- * **city** (`String`): City name. Can be `nil`.
227
- * **postal_code** (`String`): String representation of the postal code. Can be `nil`.
228
- * **state** (`String`): State name. Can be `nil`.
229
- * **country** (`String`): Country name. Can be `nil`.
230
-
231
- Note: The `value` field of an AddressField should be a concatenation of the rest of the values.
232
-
233
-
234
- ### Amount Field
235
- The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
236
-
237
-
238
- ### Classification Field
239
- The classification field `ClassificationField` does not implement all the basic `Field` attributes. It only implements
240
- **value**, **confidence** and **page_id**.
241
-
242
- > Note: a classification field's `value is always a `String`.
243
-
244
-
245
- ### Company Registration Field
246
- Aside from the basic `Field` attributes, the company registration field `CompanyRegistrationField` also implements the
247
- following:
248
-
249
- * **type** (`String`): the type of company.
250
-
251
- ### Date Field
252
- Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
253
-
254
- * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
255
-
256
- ### Locale Field
257
- The locale field `LocaleField` only implements the **value**, **confidence** and **page_id** base `Field` attributes,
258
- but it comes with its own:
259
-
260
- * **language** (`String`): ISO 639-1 language code (e.g.: `en` for English). Can be `nil`.
261
- * **country** (`String`): ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code for countries (e.g.: `GRB` or `GB` for "Great
262
- Britain"). Can be `nil`.
263
- * **currency** (`String`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `nil`.
264
-
265
- ### Payment Details Field
266
- Aside from the basic `Field` attributes, the payment details field `PaymentDetailsField` also implements the
267
- following:
268
-
269
- * **account_number** (`String`): number of an account, expressed as a string. Can be `nil`.
270
- * **iban** (`String`): International Bank Account Number. Can be `nil`.
271
- * **routing_number** (`String`): routing number of an account. Can be `nil`.
272
- * **swift** (`String`): the account holder's bank's SWIFT Business Identifier Code (BIC). Can be `nil`.
273
-
274
- ### String Field
275
- The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
276
-
277
- ### Taxes Field
278
- #### Tax
279
- Aside from the basic `Field` attributes, the tax field `TaxField` also implements the following:
280
-
281
- * **rate** (`Float`): the tax rate applied to an item can be expressed as a percentage. Can be `nil`.
282
- * **code** (`String`): tax code (or equivalent, depending on the origin of the document). Can be `nil`.
283
- * **base** (`Float`): base amount used for the tax. Can be `nil`.
284
- * **value** (`Float`): the value of the tax. Can be `nil`.
285
-
286
- > Note: currently `TaxField` is not used on its own, and is accessed through a parent `Taxes` object, an array-like
287
- structure.
288
-
289
- #### Taxes (Array)
290
- The `Taxes` field represents an array-like collection of `TaxField` objects. As it is the representation of several
291
- objects, it has access to a custom `to_s` method that can render a `TaxField` object as a table line.
292
-
293
- ## Specific Fields
294
- Fields which are specific to this product; they are not used in any other product.
295
-
296
- ### Line Items Field
297
- List of all the line items present on the invoice.
298
-
299
- A `InvoiceV4LineItem` implements the following attributes:
300
-
301
- * `description` (String): The item description.
302
- * `product_code` (String): The product code of the item.
303
- * `quantity` (Float): The item quantity
304
- * `tax_amount` (Float): The item tax amount.
305
- * `tax_rate` (Float): The item tax rate in percentage.
306
- * `total_amount` (Float): The item total amount.
307
- * `unit_measure` (String): The item unit of measure.
308
- * `unit_price` (Float): The item unit price.
309
-
310
- # Attributes
311
- The following fields are extracted for Invoice V4:
312
-
313
- ## Billing Address
314
- **billing_address** ([AddressField](#address-field)): The customer billing address.
315
-
316
- ```rb
317
- puts result.document.inference.prediction.billing_address.value
318
- ```
319
-
320
- ## Purchase Category
321
- **category** ([ClassificationField](#classification-field)): The purchase category.
322
-
323
- #### Possible values include:
324
- - 'toll'
325
- - 'food'
326
- - 'parking'
327
- - 'transport'
328
- - 'accommodation'
329
- - 'telecom'
330
- - 'miscellaneous'
331
- - 'software'
332
- - 'shopping'
333
- - 'energy'
334
-
335
- ```rb
336
- puts result.document.inference.prediction.category.value
337
- ```
338
-
339
- ## Customer Address
340
- **customer_address** ([AddressField](#address-field)): The address of the customer.
341
-
342
- ```rb
343
- puts result.document.inference.prediction.customer_address.value
344
- ```
345
-
346
- ## Customer Company Registrations
347
- **customer_company_registrations** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registration numbers associated to the customer.
348
-
349
- ```rb
350
- result.document.inference.prediction.customer_company_registrations do |customer_company_registrations_elem|
351
- puts customer_company_registrations_elem.value
352
- end
353
- ```
354
-
355
- ## Customer ID
356
- **customer_id** ([StringField](#string-field)): The customer account number or identifier from the supplier.
357
-
358
- ```rb
359
- puts result.document.inference.prediction.customer_id.value
360
- ```
361
-
362
- ## Customer Name
363
- **customer_name** ([StringField](#string-field)): The name of the customer or client.
364
-
365
- ```rb
366
- puts result.document.inference.prediction.customer_name.value
367
- ```
368
-
369
- ## Purchase Date
370
- **date** ([DateField](#date-field)): The date the purchase was made.
371
-
372
- ```rb
373
- puts result.document.inference.prediction.date.value
374
- ```
375
-
376
- ## Document Type
377
- **document_type** ([ClassificationField](#classification-field)): Document type: INVOICE or CREDIT NOTE.
378
-
379
- #### Possible values include:
380
- - 'INVOICE'
381
- - 'CREDIT NOTE'
382
-
383
- ```rb
384
- puts result.document.inference.prediction.document_type.value
385
- ```
386
-
387
- ## Document Type Extended
388
- **document_type_extended** ([ClassificationField](#classification-field)): Document type extended.
389
-
390
- #### Possible values include:
391
- - 'CREDIT NOTE'
392
- - 'INVOICE'
393
- - 'OTHER'
394
- - 'OTHER_FINANCIAL'
395
- - 'PAYSLIP'
396
- - 'PURCHASE ORDER'
397
- - 'QUOTE'
398
- - 'RECEIPT'
399
- - 'STATEMENT'
400
-
401
- ```rb
402
- puts result.document.inference.prediction.document_type_extended.value
403
- ```
404
-
405
- ## Due Date
406
- **due_date** ([DateField](#date-field)): The date on which the payment is due.
407
-
408
- ```rb
409
- puts result.document.inference.prediction.due_date.value
410
- ```
411
-
412
- ## Invoice Number
413
- **invoice_number** ([StringField](#string-field)): The invoice number or identifier.
414
-
415
- ```rb
416
- puts result.document.inference.prediction.invoice_number.value
417
- ```
418
-
419
- ## Line Items
420
- **line_items** (Array<[InvoiceV4LineItem](#line-items-field)>): List of all the line items present on the invoice.
421
-
422
- ```rb
423
- result.document.inference.prediction.line_items do |line_items_elem|
424
- puts line_items_elem.value
425
- end
426
- ```
427
-
428
- ## Locale
429
- **locale** ([LocaleField](#locale-field)): The locale of the document.
430
-
431
- ```rb
432
- puts result.document.inference.prediction.locale.value
433
- ```
434
-
435
- ## Payment Date
436
- **payment_date** ([DateField](#date-field)): The date on which the payment is due / was full-filled.
437
-
438
- ```rb
439
- puts result.document.inference.prediction.payment_date.value
440
- ```
441
-
442
- ## Purchase Order Number
443
- **po_number** ([StringField](#string-field)): The purchase order number.
444
-
445
- ```rb
446
- puts result.document.inference.prediction.po_number.value
447
- ```
448
-
449
- ## Reference Numbers
450
- **reference_numbers** (Array<[StringField](#string-field)>): List of all reference numbers on the invoice, including the purchase order number.
451
-
452
- ```rb
453
- result.document.inference.prediction.reference_numbers do |reference_numbers_elem|
454
- puts reference_numbers_elem.value
455
- end
456
- ```
457
-
458
- ## Shipping Address
459
- **shipping_address** ([AddressField](#address-field)): Customer's delivery address.
460
-
461
- ```rb
462
- puts result.document.inference.prediction.shipping_address.value
463
- ```
464
-
465
- ## Purchase Subcategory
466
- **subcategory** ([ClassificationField](#classification-field)): The purchase subcategory for transport, food and shopping.
467
-
468
- #### Possible values include:
469
- - 'plane'
470
- - 'taxi'
471
- - 'train'
472
- - 'restaurant'
473
- - 'shopping'
474
- - 'other'
475
- - 'groceries'
476
- - 'cultural'
477
- - 'electronics'
478
- - 'office_supplies'
479
- - 'micromobility'
480
- - 'car_rental'
481
- - 'public'
482
- - 'delivery'
483
- - nil
484
-
485
- ```rb
486
- puts result.document.inference.prediction.subcategory.value
487
- ```
488
-
489
- ## Supplier Address
490
- **supplier_address** ([AddressField](#address-field)): The address of the supplier or merchant.
491
-
492
- ```rb
493
- puts result.document.inference.prediction.supplier_address.value
494
- ```
495
-
496
- ## Supplier Company Registrations
497
- **supplier_company_registrations** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registration numbers associated to the supplier.
498
-
499
- ```rb
500
- result.document.inference.prediction.supplier_company_registrations do |supplier_company_registrations_elem|
501
- puts supplier_company_registrations_elem.value
502
- end
503
- ```
504
-
505
- ## Supplier Email
506
- **supplier_email** ([StringField](#string-field)): The email address of the supplier or merchant.
507
-
508
- ```rb
509
- puts result.document.inference.prediction.supplier_email.value
510
- ```
511
-
512
- ## Supplier Name
513
- **supplier_name** ([StringField](#string-field)): The name of the supplier or merchant.
514
-
515
- ```rb
516
- puts result.document.inference.prediction.supplier_name.value
517
- ```
518
-
519
- ## Supplier Payment Details
520
- **supplier_payment_details** (Array<[PaymentDetailsField](#payment-details-field)>): List of payment details associated to the supplier of the invoice.
521
-
522
- ```rb
523
- result.document.inference.prediction.supplier_payment_details do |supplier_payment_details_elem|
524
- puts supplier_payment_details_elem.value
525
- puts supplier_payment_details_elem.rate
526
- puts supplier_payment_details_elem.code
527
- puts supplier_payment_details_elem.basis
528
- end
529
- ```
530
-
531
- ## Supplier Phone Number
532
- **supplier_phone_number** ([StringField](#string-field)): The phone number of the supplier or merchant.
533
-
534
- ```rb
535
- puts result.document.inference.prediction.supplier_phone_number.value
536
- ```
537
-
538
- ## Supplier Website
539
- **supplier_website** ([StringField](#string-field)): The website URL of the supplier or merchant.
540
-
541
- ```rb
542
- puts result.document.inference.prediction.supplier_website.value
543
- ```
544
-
545
- ## Taxes
546
- **taxes** (Array<[TaxField](#taxes-field)>): List of taxes. Each item contains the detail of the tax.
547
-
548
- ```rb
549
- result.document.inference.prediction.taxes do |taxes_elem|
550
- puts taxes_elem.value
551
- end
552
- ```
553
-
554
- ## Total Amount
555
- **total_amount** ([AmountField](#amount-field)): The total amount of the invoice: includes taxes, tips, fees, and other charges.
556
-
557
- ```rb
558
- puts result.document.inference.prediction.total_amount.value
559
- ```
560
-
561
- ## Total Net
562
- **total_net** ([AmountField](#amount-field)): The net amount of the invoice: does not include taxes, fees, and discounts.
563
-
564
- ```rb
565
- puts result.document.inference.prediction.total_net.value
566
- ```
567
-
568
- ## Total Tax
569
- **total_tax** ([AmountField](#amount-field)): The total tax: the sum of all the taxes for this invoice.
570
-
571
- ```rb
572
- puts result.document.inference.prediction.total_tax.value
573
- ```
574
-
575
- # Questions?
576
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -1,131 +0,0 @@
1
- ---
2
- title: Multi Receipts Detector
3
- category: 622b805aaec68102ea7fcbc2
4
- slug: ruby-multi-receipts-detector-ocr
5
- parentDoc: 67b49df15b843f3fa9cd622b
6
- ---
7
- The Ruby Client Library supports the [Multi Receipts Detector API](https://platform.mindee.com/mindee/multi_receipts_detector).
8
-
9
-
10
- > 📝 Product Specs
11
- >
12
- > | Specification | Details |
13
- > | ------------------------------ | -------------------------------------------------- |
14
- > | Endpoint Name | `multi_receipts_detector` |
15
- > | Recommended Version | `v1.1` |
16
- > | Supports Polling/Webhooks | ❌ No |
17
- > | Support Synchronous HTTP Calls | ✔️ Yes |
18
- > | Geography | 🌐 Global |
19
-
20
-
21
- Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/multi_receipts_detector/default_sample.jpg),
22
- we are going to illustrate how to extract the data that we want using the Ruby Client Library.
23
- ![Multi Receipts Detector sample](https://github.com/mindee/client-lib-test-data/blob/main/products/multi_receipts_detector/default_sample.jpg?raw=true)
24
-
25
- # Quick-Start
26
- ```rb
27
- #
28
- # Install the Ruby client library by running:
29
- # gem install mindee
30
- #
31
-
32
- require 'mindee'
33
-
34
- # Init a new client
35
- mindee_client = Mindee::Client.new(api_key: 'my-api-key')
36
-
37
- # Load a file from disk
38
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
39
-
40
- # Parse the file
41
- result = mindee_client.parse(
42
- input_source,
43
- Mindee::Product::MultiReceiptsDetector::MultiReceiptsDetectorV1
44
- )
45
-
46
- # Print a full summary of the parsed data in RST format
47
- puts result.document
48
-
49
- # Print the document-level parsed data
50
- # puts result.document.inference.prediction
51
- ```
52
-
53
- **Output (RST):**
54
- ```rst
55
- ########
56
- Document
57
- ########
58
- :Mindee ID: d7c5b25f-e0d3-4491-af54-6183afa1aaab
59
- :Filename: default_sample.jpg
60
-
61
- Inference
62
- #########
63
- :Product: mindee/multi_receipts_detector v1.0
64
- :Rotation applied: Yes
65
-
66
- Prediction
67
- ==========
68
- :List of Receipts: Polygon with 4 points.
69
- Polygon with 4 points.
70
- Polygon with 4 points.
71
- Polygon with 4 points.
72
- Polygon with 4 points.
73
- Polygon with 4 points.
74
-
75
- Page Predictions
76
- ================
77
-
78
- Page 0
79
- ------
80
- :List of Receipts: Polygon with 4 points.
81
- Polygon with 4 points.
82
- Polygon with 4 points.
83
- Polygon with 4 points.
84
- Polygon with 4 points.
85
- Polygon with 4 points.
86
- ```
87
-
88
- # Field Types
89
- ## Standard Fields
90
- These fields are generic and used in several products.
91
-
92
- ### Basic Field
93
- Each prediction object contains a set of fields that inherit from the generic `Field` class.
94
- A typical `Field` object will have the following attributes:
95
-
96
- * **value** (`String`, `Float`, `Integer`, `bool`): corresponds to the field value. Can be `nil` if no value was extracted.
97
- * **confidence** (Float, nil): the confidence score of the field prediction.
98
- * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
99
- * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
100
- * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
101
- * **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
102
-
103
-
104
- 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.
105
-
106
-
107
- ### Position Field
108
- The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**,
109
- **polygon** and **page_id**. On top of these, it has access to:
110
-
111
- * **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond
112
- canvas).
113
- * **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
114
-
115
- # Attributes
116
- The following fields are extracted for Multi Receipts Detector V1:
117
-
118
- ## List of Receipts
119
- **receipts** (Array<[PositionField](#position-field)>): Positions of the receipts on the document.
120
-
121
- ```rb
122
- result.document.inference.prediction.receipts do |receipts_elem|
123
- puts receipts_elem.polygon.to_s
124
- puts receipts_elem.quadrangle.to_s
125
- puts receipts_elem.rectangle.to_s
126
- puts receipts_elem.boundingBox.to_s
127
- end
128
- ```
129
-
130
- # Questions?
131
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)