mindee 3.1.1 → 3.3.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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -0
  4. data/CHANGELOG.md +26 -0
  5. data/README.md +57 -7
  6. data/bin/mindee.rb +160 -83
  7. data/docs/bank_account_details_v2.md +137 -0
  8. data/docs/bank_check_v1.md +179 -0
  9. data/docs/barcode_reader_v1.md +104 -0
  10. data/docs/carte_grise_v1.md +454 -0
  11. data/docs/carte_vitale_v1.md +123 -0
  12. data/docs/code_samples/barcode_reader_v1.txt +19 -0
  13. data/docs/code_samples/carte_grise_v1.txt +19 -0
  14. data/docs/code_samples/cropper_v1.txt +16 -0
  15. data/docs/code_samples/idcard_fr_v2.txt +19 -0
  16. data/docs/code_samples/invoice_splitter_v1_async.txt +6 -54
  17. data/docs/code_samples/multi_receipts_detector_v1.txt +19 -0
  18. data/docs/code_samples/us_w9_v1.txt +16 -0
  19. data/docs/cropper_v1.md +97 -0
  20. data/docs/custom_v1.md +109 -0
  21. data/docs/expense_receipts_v5.md +306 -0
  22. data/docs/financial_document_v1.md +384 -0
  23. data/docs/{ruby-getting-started.md → getting_started.md} +22 -6
  24. data/docs/idcard_fr_v2.md +253 -0
  25. data/docs/invoice_splitter_v1.md +85 -0
  26. data/docs/invoices_v4.md +338 -0
  27. data/docs/license_plates_v1.md +91 -0
  28. data/docs/multi_receipts_detector_v1.md +105 -0
  29. data/docs/passport_v1.md +186 -0
  30. data/docs/proof_of_address_v1.md +207 -0
  31. data/docs/us_driver_license_v1.md +268 -0
  32. data/docs/us_w9_v1.md +207 -0
  33. data/lib/mindee/client.rb +95 -16
  34. data/lib/mindee/geometry/quadrilateral.rb +5 -0
  35. data/lib/mindee/http/.rubocop.yml +8 -0
  36. data/lib/mindee/http/endpoint.rb +19 -7
  37. data/lib/mindee/http/error.rb +104 -0
  38. data/lib/mindee/http.rb +1 -0
  39. data/lib/mindee/input/sources.rb +83 -14
  40. data/lib/mindee/parsing/common/api_response.rb +12 -1
  41. data/lib/mindee/parsing/common/document.rb +4 -1
  42. data/lib/mindee/parsing/common/inference.rb +2 -2
  43. data/lib/mindee/parsing/common/ocr/ocr.rb +1 -0
  44. data/lib/mindee/parsing/common.rb +0 -1
  45. data/lib/mindee/parsing/custom/list_field.rb +7 -5
  46. data/lib/mindee/parsing/standard/base_field.rb +1 -1
  47. data/lib/mindee/parsing/standard/company_registration_field.rb +1 -1
  48. data/lib/mindee/parsing/standard/locale_field.rb +1 -1
  49. data/lib/mindee/parsing/standard/payment_details_field.rb +1 -1
  50. data/lib/mindee/parsing/standard/position_field.rb +10 -3
  51. data/lib/mindee/parsing/standard/{text_field.rb → string_field.rb} +1 -1
  52. data/lib/mindee/parsing/standard.rb +1 -1
  53. data/lib/mindee/pdf/pdf_processing.rb +2 -1
  54. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +37 -0
  55. data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +44 -0
  56. data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +32 -0
  57. data/lib/mindee/product/cropper/cropper_v1.rb +37 -0
  58. data/lib/mindee/product/cropper/cropper_v1_document.rb +13 -0
  59. data/lib/mindee/product/cropper/cropper_v1_page.rb +49 -0
  60. data/lib/mindee/product/custom/custom_v1.rb +1 -0
  61. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +1 -0
  62. data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +2 -2
  63. data/lib/mindee/product/financial_document/financial_document_v1.rb +1 -0
  64. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +26 -26
  65. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +1 -0
  66. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +6 -6
  67. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +1 -0
  68. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +6 -6
  69. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +39 -0
  70. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +235 -0
  71. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_page.rb +34 -0
  72. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +1 -0
  73. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +6 -6
  74. data/lib/mindee/product/fr/id_card/id_card_v1.rb +1 -0
  75. data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +16 -16
  76. data/lib/mindee/product/fr/id_card/id_card_v2.rb +39 -0
  77. data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +107 -0
  78. data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +53 -0
  79. data/lib/mindee/product/invoice/invoice_v4.rb +2 -2
  80. data/lib/mindee/product/invoice/invoice_v4_document.rb +115 -155
  81. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +54 -30
  82. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +1 -0
  83. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +5 -3
  84. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +37 -0
  85. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +35 -0
  86. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +32 -0
  87. data/lib/mindee/product/passport/passport_v1.rb +1 -0
  88. data/lib/mindee/product/passport/passport_v1_document.rb +16 -16
  89. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +1 -0
  90. data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +14 -14
  91. data/lib/mindee/product/receipt/receipt_v4_document.rb +6 -6
  92. data/lib/mindee/product/receipt/receipt_v5.rb +1 -0
  93. data/lib/mindee/product/receipt/receipt_v5_document.rb +12 -12
  94. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +1 -0
  95. data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +8 -8
  96. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +1 -0
  97. data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +28 -28
  98. data/lib/mindee/product/us/w9/w9_v1.rb +39 -0
  99. data/lib/mindee/product/us/w9/w9_v1_document.rb +15 -0
  100. data/lib/mindee/product/us/w9/w9_v1_page.rb +102 -0
  101. data/lib/mindee/product.rb +6 -0
  102. data/lib/mindee/version.rb +5 -1
  103. data/lib/mindee.rb +45 -1
  104. metadata +48 -9
  105. data/docs/ruby-api-builder.md +0 -123
  106. data/docs/ruby-invoice-ocr.md +0 -271
  107. data/docs/ruby-passport-ocr.md +0 -165
  108. data/docs/ruby-receipt-ocr.md +0 -196
  109. data/lib/mindee/parsing/common/error.rb +0 -24
@@ -0,0 +1,85 @@
1
+ ---
2
+ title: Invoice Splitter API Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Invoice Splitter API](https://platform.mindee.com/mindee/invoice_splitter).
5
+
6
+ Using [this sample](https://github.com/mindee/client-lib-test-data/blob/main/products/invoice_splitter/default_sample.pdf), we are going to illustrate how to detect the pages of multiple invoices within the same document.
7
+
8
+ # Quick-Start
9
+
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
+ result = mindee_client.enqueue_and_parse(
20
+ input_source,
21
+ Mindee::Product::InvoiceSplitter::InvoiceSplitterV1
22
+ )
23
+
24
+ # Print a full summary of the parsed data in RST format
25
+ puts result.document
26
+
27
+ # Print the document-level parsed data
28
+ # puts result.document.inference.prediction
29
+ ```
30
+
31
+ **Output (RST):**
32
+ ```rst
33
+ ########
34
+ Document
35
+ ########
36
+ :Mindee ID: 8c25cc63-212b-4537-9c9b-3fbd3bd0ee20
37
+ :Filename: default_sample.jpg
38
+
39
+ Inference
40
+ #########
41
+ :Product: mindee/carte_vitale v1.0
42
+ :Rotation applied: Yes
43
+
44
+ Prediction
45
+ ==========
46
+ :Given Name(s): NATHALIE
47
+ :Surname: DURAND
48
+ :Social Security Number: 269054958815780
49
+ :Issuance Date: 2007-01-01
50
+
51
+ Page Predictions
52
+ ================
53
+
54
+ Page 0
55
+ ------
56
+ :Given Name(s): NATHALIE
57
+ :Surname: DURAND
58
+ :Social Security Number: 269054958815780
59
+ :Issuance Date: 2007-01-01
60
+ ```
61
+
62
+ # Field Types
63
+ ## Specific Fields
64
+ ### Invoice Splitter V1 Page Group
65
+ List of page group indexes.
66
+
67
+ An `InvoiceSplitterV1PageGroup` implements the following attributes:
68
+
69
+ * **page_indexes** (Array<`Integer`>): List of indexes of the pages of a single invoice.
70
+ * **confidence** (`Float`): The confidence of the prediction.
71
+
72
+ # Attributes
73
+ The following fields are extracted for Invoice Splitter V1:
74
+
75
+ ## Invoice Page Groups
76
+ **invoice_page_groups** (Array<[InvoiceSplitterV1PageGroup](#invoice-splitter-v1-page-group)>): List of page indexes that belong to the same invoice in the PDF.
77
+
78
+ ```rb
79
+ for invoice_page_groups_elem in result.document.inference.prediction.invoice_page_groups do
80
+ puts invoicePageGroupsElem.pageIndexes.join(', ')
81
+ end
82
+ ```
83
+
84
+ # Questions?
85
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
@@ -0,0 +1,338 @@
1
+ ---
2
+ title: Invoice OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Invoice API](https://platform.mindee.com/mindee/invoices).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/invoices/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Invoice sample](https://github.com/mindee/client-lib-test-data/blob/main/products/invoices/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.parse(
21
+ input_source,
22
+ Mindee::Product::Invoice::InvoiceV4
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
+ Document
36
+ ########
37
+ :Mindee ID: 16bd8752-8c4d-450f-8213-f33b2097504c
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/invoices v4.2
43
+ :Rotation applied: Yes
44
+
45
+ Prediction
46
+ ==========
47
+ :Locale: en; en; CAD;
48
+ :Invoice Number: 14
49
+ :Reference Numbers: AD29094
50
+ :Purchase Date: 2018-09-25
51
+ :Due Date: 2018-09-25
52
+ :Total Net:
53
+ :Total Amount: 2608.20
54
+ :Taxes:
55
+ +---------------+--------+----------+---------------+
56
+ | Base | Code | Rate (%) | Amount |
57
+ +===============+========+==========+===============+
58
+ | | | 8.00 | 193.20 |
59
+ +---------------+--------+----------+---------------+
60
+ :Supplier Payment Details:
61
+ :Supplier Name: TURNPIKE DESIGNS CO.
62
+ :Supplier Company Registrations:
63
+ :Supplier Address: 156 University Ave, Toronto ON, Canada M5H 2H7
64
+ :Customer Name: JIRO DOI
65
+ :Customer Company Registrations:
66
+ :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
67
+ :Document Type: INVOICE
68
+ :Line Items:
69
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
70
+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
71
+ +======================================+==============+==========+============+==============+==============+============+
72
+ | Platinum web hosting package Down... | | 1.00 | | | 65.00 | 65.00 |
73
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
74
+ | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | 2100.00 |
75
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
76
+ | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 250.00 |
77
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
78
+
79
+ Page Predictions
80
+ ================
81
+
82
+ Page 0
83
+ ------
84
+ :Locale: en; en; CAD;
85
+ :Invoice Number: 14
86
+ :Reference Numbers: AD29094
87
+ :Purchase Date: 2018-09-25
88
+ :Due Date: 2018-09-25
89
+ :Total Net:
90
+ :Total Amount: 2608.20
91
+ :Taxes:
92
+ +---------------+--------+----------+---------------+
93
+ | Base | Code | Rate (%) | Amount |
94
+ +===============+========+==========+===============+
95
+ | | | 8.00 | 193.20 |
96
+ +---------------+--------+----------+---------------+
97
+ :Supplier Payment Details:
98
+ :Supplier Name: TURNPIKE DESIGNS CO.
99
+ :Supplier Company Registrations:
100
+ :Supplier Address: 156 University Ave, Toronto ON, Canada M5H 2H7
101
+ :Customer Name: JIRO DOI
102
+ :Customer Company Registrations:
103
+ :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
104
+ :Document Type: INVOICE
105
+ :Line Items:
106
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
107
+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
108
+ +======================================+==============+==========+============+==============+==============+============+
109
+ | Platinum web hosting package Down... | | 1.00 | | | 65.00 | 65.00 |
110
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
111
+ | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | 2100.00 |
112
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
113
+ | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 250.00 |
114
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
115
+ ```
116
+
117
+ # Field Types
118
+ ## Standard Fields
119
+ These fields are generic and used in several products.
120
+
121
+ ### Basic Field
122
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
123
+ A typical `Field` object will have the following attributes:
124
+
125
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
126
+ * **confidence** (Float, nil): the confidence score of the field prediction.
127
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
128
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
129
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
130
+ * **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
131
+
132
+
133
+ 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.
134
+
135
+
136
+ ### Amount Field
137
+ The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
138
+
139
+
140
+ ### Classification Field
141
+ The classification field `ClassificationField` does not implement all the basic `Field` attributes. It only implements **value**, **confidence** and **page_id**.
142
+
143
+ > Note: a classification field's `value is always a `String`.
144
+
145
+
146
+ ### Company Registration Field
147
+ Aside from the basic `Field` attributes, the company registration field `CompanyRegistrationField` also implements the following:
148
+
149
+ * **type** (`String`): the type of company.
150
+
151
+ ### Date Field
152
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
153
+
154
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
155
+
156
+ ### Locale Field
157
+ The locale field `LocaleField` only implements the **value**, **confidence** and **page_id** base `Field` attributes, but it comes with its own:
158
+
159
+ * **language** (`String`): ISO 639-1 language code (e.g.: `en` for English). Can be `nil`.
160
+ * **country** (`String`): ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code for countries (e.g.: `GRB` or `GB` for "Great Britain"). Can be `nil`.
161
+ * **currency** (`String`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `nil`.
162
+
163
+ ### Payment Details Field
164
+ Aside from the basic `Field` attributes, the payment details field `PaymentDetailsField` also implements the following:
165
+
166
+ * **account_number** (`String`): number of an account, expressed as a string. Can be `nil`.
167
+ * **iban** (`String`): International Bank Account Number. Can be `nil`.
168
+ * **routing_number** (`String`): routing number of an account. Can be `nil`.
169
+ * **swift** (`String`): the account holder's bank's SWIFT Business Identifier Code (BIC). Can be `nil`.
170
+
171
+ ### String Field
172
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
173
+
174
+ ### Taxes Field
175
+ #### Tax
176
+ Aside from the basic `Field` attributes, the tax field `TaxField` also implements the following:
177
+
178
+ * **rate** (`Float`): the tax rate applied to an item can be expressed as a percentage. Can be `nil`.
179
+ * **code** (`String`): tax code (or equivalent, depending on the origin of the document). Can be `nil`.
180
+ * **base** (`Float`): base amount used for the tax. Can be `nil`.
181
+
182
+ > Note: currently `TaxField` is not used on its own, and is accessed through a parent `Taxes` object, an array-like structure.
183
+
184
+ #### Taxes (Array)
185
+ The `Taxes` field represents an array-like collection of `TaxField` objects. As it is the representation of several objects, it has access to a custom `to_s` method that can render a `TaxField` object as a table line.
186
+
187
+ ## Specific Fields
188
+ Fields which are specific to this product; they are not used in any other product.
189
+
190
+ ### Line Items Field
191
+ List of line item details.
192
+
193
+ A `InvoiceV4LineItem` implements the following attributes:
194
+
195
+ * `description` (String): The item description.
196
+ * `product_code` (String): The product code referring to the item.
197
+ * `quantity` (Float): The item quantity
198
+ * `tax_amount` (Float): The item tax amount.
199
+ * `tax_rate` (Float): The item tax rate in percentage.
200
+ * `total_amount` (Float): The item total amount.
201
+ * `unit_price` (Float): The item unit price.
202
+
203
+ # Attributes
204
+ The following fields are extracted for Invoice V4:
205
+
206
+ ## Customer Address
207
+ **customer_address** ([StringField](#string-field)): The address of the customer.
208
+
209
+ ```rb
210
+ puts result.document.inference.prediction.customer_address.value
211
+ ```
212
+
213
+ ## Customer Company Registrations
214
+ **customer_company_registrations** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations associated to the customer.
215
+
216
+ ```rb
217
+ for customer_company_registrations_elem in result.document.inference.prediction.customer_company_registrations do
218
+ puts customer_company_registrations_elem.value
219
+ end
220
+ ```
221
+
222
+ ## Customer Name
223
+ **customer_name** ([StringField](#string-field)): The name of the customer or client.
224
+
225
+ ```rb
226
+ puts result.document.inference.prediction.customer_name.value
227
+ ```
228
+
229
+ ## Purchase Date
230
+ **date** ([DateField](#date-field)): The date the purchase was made.
231
+
232
+ ```rb
233
+ puts result.document.inference.prediction.date.value
234
+ ```
235
+
236
+ ## Document Type
237
+ **document_type** ([ClassificationField](#classification-field)): One of: 'INVOICE', 'CREDIT NOTE'.
238
+
239
+ ```rb
240
+ puts result.document.inference.prediction.document_type.value
241
+ ```
242
+
243
+ ## Due Date
244
+ **due_date** ([DateField](#date-field)): The date on which the payment is due.
245
+
246
+ ```rb
247
+ puts result.document.inference.prediction.due_date.value
248
+ ```
249
+
250
+ ## Invoice Number
251
+ **invoice_number** ([StringField](#string-field)): The invoice number or identifier.
252
+
253
+ ```rb
254
+ puts result.document.inference.prediction.invoice_number.value
255
+ ```
256
+
257
+ ## Line Items
258
+ **line_items** (Array<[InvoiceV4LineItem](#line-items-field)>): List of line item details.
259
+
260
+ ```rb
261
+ for line_items_elem in result.document.inference.prediction.line_items do
262
+ puts line_items_elem.value
263
+ end
264
+ ```
265
+
266
+ ## Locale
267
+ **locale** ([LocaleField](#locale-field)): The locale detected on the document.
268
+
269
+ ```rb
270
+ puts result.document.inference.prediction.locale.value
271
+ ```
272
+
273
+ ## Reference Numbers
274
+ **reference_numbers** (Array<[StringField](#string-field)>): List of Reference numbers, including PO number.
275
+
276
+ ```rb
277
+ for reference_numbers_elem in result.document.inference.prediction.reference_numbers do
278
+ puts reference_numbers_elem.value
279
+ end
280
+ ```
281
+
282
+ ## Supplier Address
283
+ **supplier_address** ([StringField](#string-field)): The address of the supplier or merchant.
284
+
285
+ ```rb
286
+ puts result.document.inference.prediction.supplier_address.value
287
+ ```
288
+
289
+ ## Supplier Company Registrations
290
+ **supplier_company_registrations** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations associated to the supplier.
291
+
292
+ ```rb
293
+ for supplier_company_registrations_elem in result.document.inference.prediction.supplier_company_registrations do
294
+ puts supplier_company_registrations_elem.value
295
+ end
296
+ ```
297
+
298
+ ## Supplier Name
299
+ **supplier_name** ([StringField](#string-field)): The name of the supplier or merchant.
300
+
301
+ ```rb
302
+ puts result.document.inference.prediction.supplier_name.value
303
+ ```
304
+
305
+ ## Supplier Payment Details
306
+ **supplier_payment_details** (Array<[PaymentDetailsField](#payment-details-field)>): List of payment details associated to the supplier.
307
+
308
+ ```rb
309
+ for supplier_payment_details_elem in result.document.inference.prediction.supplier_payment_details do
310
+ puts supplier_payment_details_elem.value
311
+ end
312
+ ```
313
+
314
+ ## Taxes
315
+ **taxes** (Array<[TaxField](#taxes-field)>): List of tax line details.
316
+
317
+ ```rb
318
+ for taxes_elem in result.document.inference.prediction.taxes do
319
+ puts taxes_elem.to_s
320
+ end
321
+ ```
322
+
323
+ ## Total Amount
324
+ **total_amount** ([AmountField](#amount-field)): The total amount paid: includes taxes, tips, fees, and other charges.
325
+
326
+ ```rb
327
+ puts result.document.inference.prediction.total_amount.value
328
+ ```
329
+
330
+ ## Total Net
331
+ **total_net** ([AmountField](#amount-field)): The net amount paid: does not include taxes, fees, and discounts.
332
+
333
+ ```rb
334
+ puts result.document.inference.prediction.total_net.value
335
+ ```
336
+
337
+ # Questions?
338
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
@@ -0,0 +1,91 @@
1
+ ---
2
+ title: EU License Plate OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [License Plate API](https://platform.mindee.com/mindee/license_plates).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/license_plates/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![License Plate sample](https://github.com/mindee/client-lib-test-data/blob/main/products/license_plates/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.parse(
21
+ input_source,
22
+ Mindee::Product::EU::LicensePlate::LicensePlateV1
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
+ Document
36
+ ########
37
+ :Mindee ID: f0f48232-2c80-4473-9c6f-88a09111b84d
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/license_plates v1.0
43
+ :Rotation applied: No
44
+
45
+ Prediction
46
+ ==========
47
+ :License Plates: BY-323-YB
48
+
49
+ Page Predictions
50
+ ================
51
+
52
+ Page 0
53
+ ------
54
+ :License Plates: BY-323-YB
55
+ ```
56
+
57
+ # Field Types
58
+ ## Standard Fields
59
+ These fields are generic and used in several products.
60
+
61
+ ### Basic Field
62
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
63
+ A typical `Field` object will have the following attributes:
64
+
65
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
66
+ * **confidence** (Float, nil): the confidence score of the field prediction.
67
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
68
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
69
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
70
+ * **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
71
+
72
+
73
+ 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.
74
+
75
+ ### String Field
76
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
77
+
78
+ # Attributes
79
+ The following fields are extracted for License Plate V1:
80
+
81
+ ## License Plates
82
+ **license_plates** (Array<[StringField](#string-field)>): List of all license plates found in the image.
83
+
84
+ ```rb
85
+ for license_plates_elem in result.document.inference.prediction.license_plates do
86
+ puts license_plates_elem.value
87
+ end
88
+ ```
89
+
90
+ # Questions?
91
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
@@ -0,0 +1,105 @@
1
+ ---
2
+ title: Multi Receipts Detector OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Multi Receipts Detector API](https://platform.mindee.com/mindee/multi_receipts_detector).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/multi_receipts_detector/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Multi Receipts Detector sample](https://github.com/mindee/client-lib-test-data/blob/main/products/multi_receipts_detector/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.parse(
21
+ input_source,
22
+ Mindee::Product::MultiReceiptsDetector::MultiReceiptsDetectorV1
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
+ Document
36
+ ########
37
+ :Mindee ID: d7c5b25f-e0d3-4491-af54-6183afa1aaab
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/multi_receipts_detector v1.0
43
+ :Rotation applied: Yes
44
+
45
+ Prediction
46
+ ==========
47
+ :List of Receipts: Polygon with 4 points.
48
+ Polygon with 4 points.
49
+ Polygon with 4 points.
50
+ Polygon with 4 points.
51
+ Polygon with 4 points.
52
+ Polygon with 4 points.
53
+
54
+ Page Predictions
55
+ ================
56
+
57
+ Page 0
58
+ ------
59
+ :List of Receipts: Polygon with 4 points.
60
+ Polygon with 4 points.
61
+ Polygon with 4 points.
62
+ Polygon with 4 points.
63
+ Polygon with 4 points.
64
+ Polygon with 4 points.
65
+ ```
66
+
67
+ # Field Types
68
+ ## Standard Fields
69
+ These fields are generic and used in several products.
70
+
71
+ ### Basic Field
72
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
73
+ A typical `Field` object will have the following attributes:
74
+
75
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
76
+ * **confidence** (Float, nil): the confidence score of the field prediction.
77
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
78
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
79
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
80
+ * **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
81
+
82
+
83
+ 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.
84
+
85
+
86
+ ### Position Field
87
+ The position field `PositionField` does not implement all the basic `Field` attributes, only **bounding_box**, **polygon** and **page_id**. On top of these, it has access to:
88
+
89
+ * **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
90
+ * **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
91
+
92
+ # Attributes
93
+ The following fields are extracted for Multi Receipts Detector V1:
94
+
95
+ ## List of Receipts
96
+ **receipts** (Array<[PositionField](#position-field)>): Positions of the receipts on the document.
97
+
98
+ ```rb
99
+ for receipts_elem in result.document.inference.prediction.receipts do
100
+ puts receipts_elem.polygon
101
+ end
102
+ ```
103
+
104
+ # Questions?
105
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)