mindee 3.12.0 → 3.14.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 (132) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +26 -0
  4. data/README.md +23 -23
  5. data/Rakefile +5 -0
  6. data/docs/bank_account_details_v2.md +5 -1
  7. data/docs/bank_check_v1.md +6 -2
  8. data/docs/bank_statement_fr_v1.md +3 -0
  9. data/docs/barcode_reader_v1.md +5 -1
  10. data/docs/bill_of_lading_v1.md +251 -0
  11. data/docs/carte_grise_v1.md +5 -1
  12. data/docs/carte_vitale_v1.md +5 -1
  13. data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
  14. data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
  15. data/docs/code_samples/invoices_v4_async.txt +19 -0
  16. data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
  17. data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
  18. data/docs/cropper_v1.md +6 -2
  19. data/docs/custom_v1.md +5 -3
  20. data/docs/energy_bill_fra_v1.md +309 -0
  21. data/docs/eu_driver_license_v1.md +6 -2
  22. data/docs/expense_receipts_v5.md +30 -5
  23. data/docs/financial_document_v1.md +43 -1
  24. data/docs/generated_v1.md +3 -0
  25. data/docs/getting_started.md +3 -0
  26. data/docs/idcard_fr_v2.md +15 -2
  27. data/docs/international_id_v2.md +13 -1
  28. data/docs/invoice_splitter_v1.md +16 -13
  29. data/docs/invoices_v4.md +70 -23
  30. data/docs/license_plates_v1.md +5 -1
  31. data/docs/multi_receipts_detector_v1.md +5 -1
  32. data/docs/nutrition_facts_v1.md +374 -0
  33. data/docs/passport_v1.md +5 -1
  34. data/docs/payslip_fra_v2.md +294 -0
  35. data/docs/proof_of_address_v1.md +5 -1
  36. data/docs/resume_v1.md +24 -1
  37. data/docs/us_driver_license_v1.md +6 -2
  38. data/docs/us_healthcare_cards_v1.md +5 -1
  39. data/docs/us_mail_v2.md +6 -2
  40. data/docs/us_w9_v1.md +6 -2
  41. data/examples/auto_invoice_splitter_extraction.rb +48 -0
  42. data/examples/auto_multi_receipts_detector_extraction.rb +31 -0
  43. data/lib/mindee/client.rb +20 -8
  44. data/lib/mindee/{image_extraction → extraction}/common/extracted_image.rb +1 -1
  45. data/lib/mindee/extraction/common/image_extractor.rb +192 -0
  46. data/lib/mindee/{image_extraction → extraction}/common.rb +1 -0
  47. data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +32 -0
  48. data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
  49. data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
  50. data/lib/mindee/extraction/pdf_extractor.rb +4 -0
  51. data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
  52. data/lib/mindee/extraction/tax_extractor.rb +1 -320
  53. data/lib/mindee/extraction.rb +3 -0
  54. data/lib/mindee/http/endpoint.rb +18 -6
  55. data/lib/mindee/parsing/common/api_response.rb +1 -1
  56. data/lib/mindee/parsing/common/document.rb +31 -1
  57. data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
  58. data/lib/mindee/parsing/common/extras/extras.rb +50 -0
  59. data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
  60. data/lib/mindee/parsing/common/extras.rb +5 -0
  61. data/lib/mindee/parsing/common/page.rb +5 -0
  62. data/lib/mindee/parsing/standard/base_field.rb +1 -0
  63. data/lib/mindee/parsing/standard/date_field.rb +4 -0
  64. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
  65. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
  66. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
  67. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
  68. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
  69. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
  70. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
  71. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
  72. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +11 -1
  73. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +15 -1
  74. data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
  75. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
  76. data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
  77. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
  78. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
  79. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
  80. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
  81. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
  82. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
  83. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
  84. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
  85. data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
  86. data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
  87. data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
  88. data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
  89. data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
  90. data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
  91. data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
  92. data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
  93. data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
  94. data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
  95. data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
  96. data/lib/mindee/product/invoice/invoice_v4_document.rb +11 -1
  97. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +15 -1
  98. data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
  99. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
  100. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
  101. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
  102. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
  103. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
  104. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
  105. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
  106. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
  107. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
  108. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
  109. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
  110. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
  111. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
  112. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
  113. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
  114. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
  115. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
  116. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
  117. data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
  118. data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
  119. data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
  120. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
  121. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
  122. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +9 -1
  123. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
  124. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
  125. data/lib/mindee/product.rb +5 -1
  126. data/lib/mindee/version.rb +1 -1
  127. metadata +71 -9
  128. data/lib/mindee/image_extraction/common/image_extractor.rb +0 -191
  129. data/lib/mindee/image_extraction/multi_receipts_extractor/multi_receipts_extractor.rb +0 -26
  130. data/lib/mindee/image_extraction.rb +0 -4
  131. /data/lib/mindee/{image_extraction → extraction}/multi_receipts_extractor.rb +0 -0
  132. /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: Invoice Splitter API Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-invoice-splitter-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
3
6
  ---
4
7
  The Ruby OCR SDK supports the [Invoice Splitter API](https://platform.mindee.com/mindee/invoice_splitter).
5
8
 
@@ -33,30 +36,30 @@ puts result.document
33
36
  ########
34
37
  Document
35
38
  ########
36
- :Mindee ID: 8c25cc63-212b-4537-9c9b-3fbd3bd0ee20
37
- :Filename: default_sample.jpg
39
+ :Mindee ID: 15ad7a19-7b75-43d0-b0c6-9a641a12b49b
40
+ :Filename: default_sample.pdf
38
41
 
39
42
  Inference
40
43
  #########
41
- :Product: mindee/carte_vitale v1.0
42
- :Rotation applied: Yes
44
+ :Product: mindee/invoice_splitter v1.1
45
+ :Rotation applied: No
43
46
 
44
47
  Prediction
45
48
  ==========
46
- :Given Name(s): NATHALIE
47
- :Surname: DURAND
48
- :Social Security Number: 269054958815780
49
- :Issuance Date: 2007-01-01
49
+ :Invoice Page Groups:
50
+ :Page indexes: 0
51
+ :Page indexes: 1
50
52
 
51
53
  Page Predictions
52
54
  ================
53
55
 
54
56
  Page 0
55
57
  ------
56
- :Given Name(s): NATHALIE
57
- :Surname: DURAND
58
- :Social Security Number: 269054958815780
59
- :Issuance Date: 2007-01-01
58
+ :Invoice Page Groups:
59
+
60
+ Page 1
61
+ ------
62
+ :Invoice Page Groups:
60
63
  ```
61
64
 
62
65
  # Field Types
@@ -77,7 +80,7 @@ The following fields are extracted for Invoice Splitter V1:
77
80
 
78
81
  ```rb
79
82
  for invoice_page_groups_elem in result.document.inference.prediction.invoice_page_groups do
80
- puts invoicePageGroupsElem.pageIndexes.join(', ')
83
+ puts invoice_page_groups_elem.page_indexes.join(', ')
81
84
  end
82
85
  ```
83
86
 
data/docs/invoices_v4.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: Invoice OCR Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-invoice-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
3
6
  ---
4
7
  The Ruby OCR SDK supports the [Invoice API](https://platform.mindee.com/mindee/invoices).
5
8
 
@@ -27,6 +30,32 @@ puts result.document
27
30
 
28
31
  # Print the document-level parsed data
29
32
  # puts result.document.inference.prediction
33
+
34
+ ```
35
+
36
+ You can also call this product asynchronously:
37
+
38
+ ```rb
39
+ require 'mindee'
40
+
41
+ # Init a new client
42
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
43
+
44
+ # Load a file from disk
45
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
46
+
47
+ # Parse the file
48
+ result = mindee_client.enqueue_and_parse(
49
+ input_source,
50
+ Mindee::Product::Invoice::InvoiceV4
51
+ )
52
+
53
+ # Print a full summary of the parsed data in RST format
54
+ puts result.document
55
+
56
+ # Print the document-level parsed data
57
+ # puts result.document.inference.prediction
58
+
30
59
  ```
31
60
 
32
61
  **Output (RST):**
@@ -34,12 +63,12 @@ puts result.document
34
63
  ########
35
64
  Document
36
65
  ########
37
- :Mindee ID: 128a314f-1adb-42eb-a9e3-402055a8b8ce
66
+ :Mindee ID: 372d9d08-59d8-4e1c-9622-06648c1c238b
38
67
  :Filename: default_sample.jpg
39
68
 
40
69
  Inference
41
70
  #########
42
- :Product: mindee/invoices v4.6
71
+ :Product: mindee/invoices v4.7
43
72
  :Rotation applied: Yes
44
73
 
45
74
  Prediction
@@ -64,7 +93,7 @@ Prediction
64
93
  :Supplier Address: 156 University Ave, Toronto ON, Canada, M5H 2H7
65
94
  :Supplier Phone Number: 4165551212
66
95
  :Supplier Website:
67
- :Supplier Email: i_doi@example.com
96
+ :Supplier Email: ldoi@example.com
68
97
  :Customer Name: JIRO DOI
69
98
  :Customer Company Registrations:
70
99
  :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
@@ -73,15 +102,15 @@ Prediction
73
102
  :Billing Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
74
103
  :Document Type: INVOICE
75
104
  :Line Items:
76
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
77
- | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
78
- +======================================+==============+==========+============+==============+==============+============+
79
- | Platinum web hosting package Down... | | 1.00 | | | 65.00 | 65.00 |
80
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
81
- | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | 2100.00 |
82
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
83
- | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 250.00 |
84
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
105
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
106
+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit of measure | Unit Price |
107
+ +======================================+==============+==========+============+==============+==============+=================+============+
108
+ | Platinum web hosting package Down... | | 1.00 | | | 65.00 | | 65.00 |
109
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
110
+ | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | | 2100.00 |
111
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
112
+ | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 1 | 250.00 |
113
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
85
114
 
86
115
  Page Predictions
87
116
  ================
@@ -108,7 +137,7 @@ Page 0
108
137
  :Supplier Address: 156 University Ave, Toronto ON, Canada, M5H 2H7
109
138
  :Supplier Phone Number: 4165551212
110
139
  :Supplier Website:
111
- :Supplier Email: i_doi@example.com
140
+ :Supplier Email: ldoi@example.com
112
141
  :Customer Name: JIRO DOI
113
142
  :Customer Company Registrations:
114
143
  :Customer Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
@@ -117,15 +146,15 @@ Page 0
117
146
  :Billing Address: 1954 Bloor Street West Toronto, ON, M6P 3K9 Canada
118
147
  :Document Type: INVOICE
119
148
  :Line Items:
120
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
121
- | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
122
- +======================================+==============+==========+============+==============+==============+============+
123
- | Platinum web hosting package Down... | | 1.00 | | | 65.00 | 65.00 |
124
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
125
- | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | 2100.00 |
126
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
127
- | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 250.00 |
128
- +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
149
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
150
+ | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit of measure | Unit Price |
151
+ +======================================+==============+==========+============+==============+==============+=================+============+
152
+ | Platinum web hosting package Down... | | 1.00 | | | 65.00 | | 65.00 |
153
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
154
+ | 2 page website design Includes ba... | | 3.00 | | | 2100.00 | | 2100.00 |
155
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
156
+ | Mobile designs Includes responsiv... | | 1.00 | | | 250.00 | 1 | 250.00 |
157
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+-----------------+------------+
129
158
  ```
130
159
 
131
160
  # Field Types
@@ -140,7 +169,7 @@ A typical `Field` object will have the following attributes:
140
169
  * **confidence** (Float, nil): the confidence score of the field prediction.
141
170
  * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
142
171
  * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
143
- * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
172
+ * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
144
173
  * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
145
174
 
146
175
 
@@ -265,6 +294,10 @@ puts result.document.inference.prediction.date.value
265
294
  ## Document Type
266
295
  **document_type** ([ClassificationField](#classification-field)): One of: 'INVOICE', 'CREDIT NOTE'.
267
296
 
297
+ #### Possible values include:
298
+ - INVOICE
299
+ - CREDIT NOTE
300
+
268
301
  ```rb
269
302
  puts result.document.inference.prediction.document_type.value
270
303
  ```
@@ -299,6 +332,20 @@ end
299
332
  puts result.document.inference.prediction.locale.value
300
333
  ```
301
334
 
335
+ ## Payment Date
336
+ **payment_date** ([DateField](#date-field)): The date on which the payment is due/ was full-filled.
337
+
338
+ ```rb
339
+ puts result.document.inference.prediction.payment_date.value
340
+ ```
341
+
342
+ ## Purchase Order Number
343
+ **po_number** ([StringField](#string-field)): The purchase order number.
344
+
345
+ ```rb
346
+ puts result.document.inference.prediction.po_number.value
347
+ ```
348
+
302
349
  ## Reference Numbers
303
350
  **reference_numbers** (Array<[StringField](#string-field)>): List of Reference numbers, including PO number.
304
351
 
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: EU License Plate OCR Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-eu-license-plate-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
3
6
  ---
4
7
  The Ruby OCR SDK supports the [License Plate API](https://platform.mindee.com/mindee/license_plates).
5
8
 
@@ -27,6 +30,7 @@ puts result.document
27
30
 
28
31
  # Print the document-level parsed data
29
32
  # puts result.document.inference.prediction
33
+
30
34
  ```
31
35
 
32
36
  **Output (RST):**
@@ -66,7 +70,7 @@ A typical `Field` object will have the following attributes:
66
70
  * **confidence** (Float, nil): the confidence score of the field prediction.
67
71
  * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
68
72
  * **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.
73
+ * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
70
74
  * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
71
75
 
72
76
 
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: Multi Receipts Detector OCR Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-multi-receipts-detector-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
3
6
  ---
4
7
  The Ruby OCR SDK supports the [Multi Receipts Detector API](https://platform.mindee.com/mindee/multi_receipts_detector).
5
8
 
@@ -27,6 +30,7 @@ puts result.document
27
30
 
28
31
  # Print the document-level parsed data
29
32
  # puts result.document.inference.prediction
33
+
30
34
  ```
31
35
 
32
36
  **Output (RST):**
@@ -76,7 +80,7 @@ A typical `Field` object will have the following attributes:
76
80
  * **confidence** (Float, nil): the confidence score of the field prediction.
77
81
  * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
78
82
  * **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.
83
+ * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
80
84
  * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
81
85
 
82
86
 
@@ -0,0 +1,374 @@
1
+ ---
2
+ title: Nutrition Facts Label OCR Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-nutrition-facts-label-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
6
+ ---
7
+ The Ruby OCR SDK supports the [Nutrition Facts Label API](https://platform.mindee.com/mindee/nutrition_facts).
8
+
9
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/nutrition_facts/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
10
+ ![Nutrition Facts Label sample](https://github.com/mindee/client-lib-test-data/blob/main/products/nutrition_facts/default_sample.jpg?raw=true)
11
+
12
+ # Quick-Start
13
+ ```rb
14
+ require 'mindee'
15
+
16
+ # Init a new client
17
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
18
+
19
+ # Load a file from disk
20
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
21
+
22
+ # Parse the file
23
+ result = mindee_client.enqueue_and_parse(
24
+ input_source,
25
+ Mindee::Product::NutritionFactsLabel::NutritionFactsLabelV1
26
+ )
27
+
28
+ # Print a full summary of the parsed data in RST format
29
+ puts result.document
30
+
31
+ # Print the document-level parsed data
32
+ # puts result.document.inference.prediction
33
+
34
+ ```
35
+
36
+ **Output (RST):**
37
+ ```rst
38
+ ########
39
+ Document
40
+ ########
41
+ :Mindee ID: 38a12fe0-5d69-4ca4-9b30-12f1b659311c
42
+ :Filename: default_sample.jpg
43
+
44
+ Inference
45
+ #########
46
+ :Product: mindee/nutrition_facts v1.0
47
+ :Rotation applied: No
48
+
49
+ Prediction
50
+ ==========
51
+ :Serving per Box: 2.00
52
+ :Serving Size:
53
+ :Amount: 228.00
54
+ :Unit: g
55
+ :Calories:
56
+ :Daily Value:
57
+ :Per 100g:
58
+ :Per Serving: 250.00
59
+ :Total Fat:
60
+ :Daily Value:
61
+ :Per 100g:
62
+ :Per Serving: 12.00
63
+ :Saturated Fat:
64
+ :Daily Value: 15.00
65
+ :Per 100g:
66
+ :Per Serving: 3.00
67
+ :Trans Fat:
68
+ :Daily Value:
69
+ :Per 100g:
70
+ :Per Serving: 3.00
71
+ :Cholesterol:
72
+ :Daily Value: 10.00
73
+ :Per 100g:
74
+ :Per Serving: 30.00
75
+ :Total Carbohydrate:
76
+ :Daily Value: 10.00
77
+ :Per 100g:
78
+ :Per Serving: 31.00
79
+ :Dietary Fiber:
80
+ :Daily Value: 0.00
81
+ :Per 100g:
82
+ :Per Serving: 0.00
83
+ :Total Sugars:
84
+ :Daily Value:
85
+ :Per 100g:
86
+ :Per Serving: 5.00
87
+ :Added Sugars:
88
+ :Daily Value:
89
+ :Per 100g:
90
+ :Per Serving:
91
+ :Protein:
92
+ :Daily Value:
93
+ :Per 100g:
94
+ :Per Serving: 5.00
95
+ :sodium:
96
+ :Daily Value: 20.00
97
+ :Per 100g:
98
+ :Per Serving: 470.00
99
+ :Unit: mg
100
+ :nutrients:
101
+ +-------------+----------------------+----------+-------------+------+
102
+ | Daily Value | Name | Per 100g | Per Serving | Unit |
103
+ +=============+======================+==========+=============+======+
104
+ | 12.00 | Vitamin A | | 4.00 | mcg |
105
+ +-------------+----------------------+----------+-------------+------+
106
+ | 12.00 | Vitamin C | | 2.00 | mg |
107
+ +-------------+----------------------+----------+-------------+------+
108
+ | 12.00 | Calcium | | 45.60 | mg |
109
+ +-------------+----------------------+----------+-------------+------+
110
+ | 12.00 | Iron | | 0.90 | mg |
111
+ +-------------+----------------------+----------+-------------+------+
112
+ ```
113
+
114
+ # Field Types
115
+ ## Standard Fields
116
+ These fields are generic and used in several products.
117
+
118
+ ### Basic Field
119
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
120
+ A typical `Field` object will have the following attributes:
121
+
122
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
123
+ * **confidence** (Float, nil): the confidence score of the field prediction.
124
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
125
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
126
+ * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
127
+ * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
128
+
129
+
130
+ 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.
131
+
132
+
133
+ ### Amount Field
134
+ The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
135
+
136
+ ## Specific Fields
137
+ Fields which are specific to this product; they are not used in any other product.
138
+
139
+ ### Added Sugars Field
140
+ The amount of added sugars in the product.
141
+
142
+ A `NutritionFactsLabelV1AddedSugar` implements the following attributes:
143
+
144
+ * `daily_value` (Float): DVs are the recommended amounts of added sugars to consume or not to exceed each day.
145
+ * `per_100g` (Float): The amount of added sugars per 100g of the product.
146
+ * `per_serving` (Float): The amount of added sugars per serving of the product.
147
+ Fields which are specific to this product; they are not used in any other product.
148
+
149
+ ### Calories Field
150
+ The amount of calories in the product.
151
+
152
+ A `NutritionFactsLabelV1Calorie` implements the following attributes:
153
+
154
+ * `daily_value` (Float): DVs are the recommended amounts of calories to consume or not to exceed each day.
155
+ * `per_100g` (Float): The amount of calories per 100g of the product.
156
+ * `per_serving` (Float): The amount of calories per serving of the product.
157
+ Fields which are specific to this product; they are not used in any other product.
158
+
159
+ ### Cholesterol Field
160
+ The amount of cholesterol in the product.
161
+
162
+ A `NutritionFactsLabelV1Cholesterol` implements the following attributes:
163
+
164
+ * `daily_value` (Float): DVs are the recommended amounts of cholesterol to consume or not to exceed each day.
165
+ * `per_100g` (Float): The amount of cholesterol per 100g of the product.
166
+ * `per_serving` (Float): The amount of cholesterol per serving of the product.
167
+ Fields which are specific to this product; they are not used in any other product.
168
+
169
+ ### Dietary Fiber Field
170
+ The amount of dietary fiber in the product.
171
+
172
+ A `NutritionFactsLabelV1DietaryFiber` implements the following attributes:
173
+
174
+ * `daily_value` (Float): DVs are the recommended amounts of dietary fiber to consume or not to exceed each day.
175
+ * `per_100g` (Float): The amount of dietary fiber per 100g of the product.
176
+ * `per_serving` (Float): The amount of dietary fiber per serving of the product.
177
+ Fields which are specific to this product; they are not used in any other product.
178
+
179
+ ### nutrients Field
180
+ The amount of nutrients in the product.
181
+
182
+ A `NutritionFactsLabelV1Nutrient` implements the following attributes:
183
+
184
+ * `daily_value` (Float): DVs are the recommended amounts of nutrients to consume or not to exceed each day.
185
+ * `name` (String): The name of nutrients of the product.
186
+ * `per_100g` (Float): The amount of nutrients per 100g of the product.
187
+ * `per_serving` (Float): The amount of nutrients per serving of the product.
188
+ * `unit` (String): The unit of measurement for the amount of nutrients.
189
+ Fields which are specific to this product; they are not used in any other product.
190
+
191
+ ### Protein Field
192
+ The amount of protein in the product.
193
+
194
+ A `NutritionFactsLabelV1Protein` implements the following attributes:
195
+
196
+ * `daily_value` (Float): DVs are the recommended amounts of protein to consume or not to exceed each day.
197
+ * `per_100g` (Float): The amount of protein per 100g of the product.
198
+ * `per_serving` (Float): The amount of protein per serving of the product.
199
+ Fields which are specific to this product; they are not used in any other product.
200
+
201
+ ### Saturated Fat Field
202
+ The amount of saturated fat in the product.
203
+
204
+ A `NutritionFactsLabelV1SaturatedFat` implements the following attributes:
205
+
206
+ * `daily_value` (Float): DVs are the recommended amounts of saturated fat to consume or not to exceed each day.
207
+ * `per_100g` (Float): The amount of saturated fat per 100g of the product.
208
+ * `per_serving` (Float): The amount of saturated fat per serving of the product.
209
+ Fields which are specific to this product; they are not used in any other product.
210
+
211
+ ### Serving Size Field
212
+ The size of a single serving of the product.
213
+
214
+ A `NutritionFactsLabelV1ServingSize` implements the following attributes:
215
+
216
+ * `amount` (Float): The amount of a single serving.
217
+ * `unit` (String): The unit for the amount of a single serving.
218
+ Fields which are specific to this product; they are not used in any other product.
219
+
220
+ ### sodium Field
221
+ The amount of sodium in the product.
222
+
223
+ A `NutritionFactsLabelV1Sodium` implements the following attributes:
224
+
225
+ * `daily_value` (Float): DVs are the recommended amounts of sodium to consume or not to exceed each day.
226
+ * `per_100g` (Float): The amount of sodium per 100g of the product.
227
+ * `per_serving` (Float): The amount of sodium per serving of the product.
228
+ * `unit` (String): The unit of measurement for the amount of sodium.
229
+ Fields which are specific to this product; they are not used in any other product.
230
+
231
+ ### Total Carbohydrate Field
232
+ The total amount of carbohydrates in the product.
233
+
234
+ A `NutritionFactsLabelV1TotalCarbohydrate` implements the following attributes:
235
+
236
+ * `daily_value` (Float): DVs are the recommended amounts of total carbohydrates to consume or not to exceed each day.
237
+ * `per_100g` (Float): The amount of total carbohydrates per 100g of the product.
238
+ * `per_serving` (Float): The amount of total carbohydrates per serving of the product.
239
+ Fields which are specific to this product; they are not used in any other product.
240
+
241
+ ### Total Fat Field
242
+ The total amount of fat in the product.
243
+
244
+ A `NutritionFactsLabelV1TotalFat` implements the following attributes:
245
+
246
+ * `daily_value` (Float): DVs are the recommended amounts of total fat to consume or not to exceed each day.
247
+ * `per_100g` (Float): The amount of total fat per 100g of the product.
248
+ * `per_serving` (Float): The amount of total fat per serving of the product.
249
+ Fields which are specific to this product; they are not used in any other product.
250
+
251
+ ### Total Sugars Field
252
+ The total amount of sugars in the product.
253
+
254
+ A `NutritionFactsLabelV1TotalSugar` implements the following attributes:
255
+
256
+ * `daily_value` (Float): DVs are the recommended amounts of total sugars to consume or not to exceed each day.
257
+ * `per_100g` (Float): The amount of total sugars per 100g of the product.
258
+ * `per_serving` (Float): The amount of total sugars per serving of the product.
259
+ Fields which are specific to this product; they are not used in any other product.
260
+
261
+ ### Trans Fat Field
262
+ The amount of trans fat in the product.
263
+
264
+ A `NutritionFactsLabelV1TransFat` implements the following attributes:
265
+
266
+ * `daily_value` (Float): DVs are the recommended amounts of trans fat to consume or not to exceed each day.
267
+ * `per_100g` (Float): The amount of trans fat per 100g of the product.
268
+ * `per_serving` (Float): The amount of trans fat per serving of the product.
269
+
270
+ # Attributes
271
+ The following fields are extracted for Nutrition Facts Label V1:
272
+
273
+ ## Added Sugars
274
+ **added_sugars** ([NutritionFactsLabelV1AddedSugar](#added-sugars-field)): The amount of added sugars in the product.
275
+
276
+ ```rb
277
+ puts result.document.inference.prediction.added_sugars.value
278
+ ```
279
+
280
+ ## Calories
281
+ **calories** ([NutritionFactsLabelV1Calorie](#calories-field)): The amount of calories in the product.
282
+
283
+ ```rb
284
+ puts result.document.inference.prediction.calories.value
285
+ ```
286
+
287
+ ## Cholesterol
288
+ **cholesterol** ([NutritionFactsLabelV1Cholesterol](#cholesterol-field)): The amount of cholesterol in the product.
289
+
290
+ ```rb
291
+ puts result.document.inference.prediction.cholesterol.value
292
+ ```
293
+
294
+ ## Dietary Fiber
295
+ **dietary_fiber** ([NutritionFactsLabelV1DietaryFiber](#dietary-fiber-field)): The amount of dietary fiber in the product.
296
+
297
+ ```rb
298
+ puts result.document.inference.prediction.dietary_fiber.value
299
+ ```
300
+
301
+ ## nutrients
302
+ **nutrients** (Array<[NutritionFactsLabelV1Nutrient](#nutrients-field)>): The amount of nutrients in the product.
303
+
304
+ ```rb
305
+ for nutrients_elem in result.document.inference.prediction.nutrients do
306
+ puts nutrients_elem.value
307
+ end
308
+ ```
309
+
310
+ ## Protein
311
+ **protein** ([NutritionFactsLabelV1Protein](#protein-field)): The amount of protein in the product.
312
+
313
+ ```rb
314
+ puts result.document.inference.prediction.protein.value
315
+ ```
316
+
317
+ ## Saturated Fat
318
+ **saturated_fat** ([NutritionFactsLabelV1SaturatedFat](#saturated-fat-field)): The amount of saturated fat in the product.
319
+
320
+ ```rb
321
+ puts result.document.inference.prediction.saturated_fat.value
322
+ ```
323
+
324
+ ## Serving per Box
325
+ **serving_per_box** ([AmountField](#amount-field)): The number of servings in each box of the product.
326
+
327
+ ```rb
328
+ puts result.document.inference.prediction.serving_per_box.value
329
+ ```
330
+
331
+ ## Serving Size
332
+ **serving_size** ([NutritionFactsLabelV1ServingSize](#serving-size-field)): The size of a single serving of the product.
333
+
334
+ ```rb
335
+ puts result.document.inference.prediction.serving_size.value
336
+ ```
337
+
338
+ ## sodium
339
+ **sodium** ([NutritionFactsLabelV1Sodium](#sodium-field)): The amount of sodium in the product.
340
+
341
+ ```rb
342
+ puts result.document.inference.prediction.sodium.value
343
+ ```
344
+
345
+ ## Total Carbohydrate
346
+ **total_carbohydrate** ([NutritionFactsLabelV1TotalCarbohydrate](#total-carbohydrate-field)): The total amount of carbohydrates in the product.
347
+
348
+ ```rb
349
+ puts result.document.inference.prediction.total_carbohydrate.value
350
+ ```
351
+
352
+ ## Total Fat
353
+ **total_fat** ([NutritionFactsLabelV1TotalFat](#total-fat-field)): The total amount of fat in the product.
354
+
355
+ ```rb
356
+ puts result.document.inference.prediction.total_fat.value
357
+ ```
358
+
359
+ ## Total Sugars
360
+ **total_sugars** ([NutritionFactsLabelV1TotalSugar](#total-sugars-field)): The total amount of sugars in the product.
361
+
362
+ ```rb
363
+ puts result.document.inference.prediction.total_sugars.value
364
+ ```
365
+
366
+ ## Trans Fat
367
+ **trans_fat** ([NutritionFactsLabelV1TransFat](#trans-fat-field)): The amount of trans fat in the product.
368
+
369
+ ```rb
370
+ puts result.document.inference.prediction.trans_fat.value
371
+ ```
372
+
373
+ # Questions?
374
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
data/docs/passport_v1.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: Passport OCR Ruby
3
+ category: 622b805aaec68102ea7fcbc2
4
+ slug: ruby-passport-ocr
5
+ parentDoc: 6294d97ee723f1008d2ab28e
3
6
  ---
4
7
  The Ruby OCR SDK supports the [Passport API](https://platform.mindee.com/mindee/passport).
5
8
 
@@ -27,6 +30,7 @@ puts result.document
27
30
 
28
31
  # Print the document-level parsed data
29
32
  # puts result.document.inference.prediction
33
+
30
34
  ```
31
35
 
32
36
  **Output (RST):**
@@ -86,7 +90,7 @@ A typical `Field` object will have the following attributes:
86
90
  * **confidence** (Float, nil): the confidence score of the field prediction.
87
91
  * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
88
92
  * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
89
- * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
93
+ * **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
90
94
  * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
91
95
 
92
96