mindee 3.4.0 → 3.6.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +6 -1
  4. data/bin/mindee.rb +45 -15
  5. data/docs/bank_account_details_v2.md +1 -1
  6. data/docs/bank_check_v1.md +1 -1
  7. data/docs/bank_statement_fr_v1.md +175 -0
  8. data/docs/barcode_reader_v1.md +1 -1
  9. data/docs/carte_grise_v1.md +5 -5
  10. data/docs/carte_vitale_v1.md +1 -1
  11. data/docs/code_samples/bank_statement_fr_v1_async.txt +19 -0
  12. data/docs/code_samples/default.txt +19 -19
  13. data/docs/code_samples/default_async.txt +25 -0
  14. data/docs/code_samples/eu_driver_license_v1.txt +19 -0
  15. data/docs/code_samples/international_id_v1_async.txt +19 -0
  16. data/docs/code_samples/international_id_v2_async.txt +19 -0
  17. data/docs/code_samples/resume_v1_async.txt +19 -0
  18. data/docs/cropper_v1.md +1 -1
  19. data/docs/custom_v1.md +1 -1
  20. data/docs/eu_driver_license_v1.md +223 -0
  21. data/docs/expense_receipts_v5.md +1 -1
  22. data/docs/financial_document_v1.md +49 -41
  23. data/docs/generated_v1.md +90 -0
  24. data/docs/getting_started.md +1 -1
  25. data/docs/idcard_fr_v2.md +1 -1
  26. data/docs/international_id_v2.md +195 -0
  27. data/docs/invoice_splitter_v1.md +1 -1
  28. data/docs/invoices_v4.md +5 -2
  29. data/docs/license_plates_v1.md +1 -1
  30. data/docs/multi_receipts_detector_v1.md +1 -1
  31. data/docs/passport_v1.md +1 -1
  32. data/docs/proof_of_address_v1.md +5 -5
  33. data/docs/resume_v1.md +334 -0
  34. data/docs/us_driver_license_v1.md +3 -3
  35. data/docs/us_w9_v1.md +1 -1
  36. data/lib/mindee/client.rb +5 -3
  37. data/lib/mindee/http/endpoint.rb +13 -12
  38. data/lib/mindee/input/sources.rb +28 -5
  39. data/lib/mindee/parsing/common/inference.rb +3 -1
  40. data/lib/mindee/parsing/generated/generated_list_field.rb +58 -0
  41. data/lib/mindee/parsing/generated/generated_object_field.rb +109 -0
  42. data/lib/mindee/parsing/generated.rb +4 -0
  43. data/lib/mindee/parsing/standard/base_field.rb +1 -1
  44. data/lib/mindee/parsing.rb +1 -0
  45. data/lib/mindee/product/.rubocop.yml +7 -2
  46. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +3 -1
  47. data/lib/mindee/product/cropper/cropper_v1.rb +3 -1
  48. data/lib/mindee/product/eu/driver_license/driver_license_v1.rb +41 -0
  49. data/lib/mindee/product/eu/driver_license/driver_license_v1_document.rb +88 -0
  50. data/lib/mindee/product/eu/driver_license/driver_license_v1_page.rb +53 -0
  51. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +3 -1
  52. data/lib/mindee/product/financial_document/financial_document_v1.rb +3 -1
  53. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +3 -1
  54. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +3 -1
  55. data/lib/mindee/product/fr/bank_statement/bank_statement_v1.rb +41 -0
  56. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_document.rb +130 -0
  57. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_page.rb +34 -0
  58. data/lib/mindee/product/fr/bank_statement/bank_statement_v1_transaction.rb +64 -0
  59. data/lib/mindee/product/fr/carte_grise/carte_grise_v1.rb +3 -1
  60. data/lib/mindee/product/fr/carte_grise/carte_grise_v1_document.rb +0 -2
  61. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +3 -1
  62. data/lib/mindee/product/fr/id_card/id_card_v1.rb +3 -1
  63. data/lib/mindee/product/fr/id_card/id_card_v2.rb +3 -1
  64. data/lib/mindee/product/generated/generated_v1.rb +38 -0
  65. data/lib/mindee/product/generated/generated_v1_document.rb +35 -0
  66. data/lib/mindee/product/generated/generated_v1_page.rb +51 -0
  67. data/lib/mindee/product/generated/generated_v1_prediction.rb +114 -0
  68. data/lib/mindee/product/international_id/international_id_v1.rb +39 -0
  69. data/lib/mindee/product/international_id/international_id_v1_document.rb +109 -0
  70. data/lib/mindee/product/international_id/international_id_v1_page.rb +32 -0
  71. data/lib/mindee/product/international_id/international_id_v2.rb +39 -0
  72. data/lib/mindee/product/international_id/international_id_v2_document.rb +119 -0
  73. data/lib/mindee/product/international_id/international_id_v2_page.rb +32 -0
  74. data/lib/mindee/product/invoice/invoice_v4.rb +3 -1
  75. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +3 -1
  76. data/lib/mindee/product/passport/passport_v1.rb +3 -1
  77. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +3 -1
  78. data/lib/mindee/product/receipt/receipt_v5.rb +3 -1
  79. data/lib/mindee/product/resume/resume_v1.rb +39 -0
  80. data/lib/mindee/product/resume/resume_v1_certificate.rb +69 -0
  81. data/lib/mindee/product/resume/resume_v1_document.rb +322 -0
  82. data/lib/mindee/product/resume/resume_v1_education.rb +90 -0
  83. data/lib/mindee/product/resume/resume_v1_language.rb +55 -0
  84. data/lib/mindee/product/resume/resume_v1_page.rb +32 -0
  85. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +97 -0
  86. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +55 -0
  87. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +3 -1
  88. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +3 -1
  89. data/lib/mindee/product/us/w9/w9_v1.rb +3 -1
  90. data/lib/mindee/product.rb +6 -0
  91. data/lib/mindee/version.rb +1 -1
  92. data/lib/mindee.rb +4 -0
  93. metadata +41 -2
@@ -0,0 +1,223 @@
1
+ ---
2
+ title: EU Driver License OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/eu_driver_license).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/eu_driver_license/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Driver License sample](https://github.com/mindee/client-lib-test-data/blob/main/products/eu_driver_license/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::DriverLicense::DriverLicenseV1
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: b19cc32e-b3e6-4ff9-bdc7-619199355d54
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/eu_driver_license v1.0
43
+ :Rotation applied: Yes
44
+
45
+ Prediction
46
+ ==========
47
+ :Country Code: FR
48
+ :Document ID: 13AA00002
49
+ :Driver License Category: AM A1 B1 B D BE DE
50
+ :Last Name: MARTIN
51
+ :First Name: PAUL
52
+ :Date Of Birth: 1981-07-14
53
+ :Place Of Birth: Utopiacity
54
+ :Expiry Date: 2018-12-31
55
+ :Issue Date: 2013-01-01
56
+ :Issue Authority: 99999UpiaCity
57
+ :MRZ: D1FRA13AA000026181231MARTIN<<9
58
+ :Address:
59
+
60
+ Page Predictions
61
+ ================
62
+
63
+ Page 0
64
+ ------
65
+ :Photo: Polygon with 4 points.
66
+ :Signature: Polygon with 4 points.
67
+ :Country Code: FR
68
+ :Document ID: 13AA00002
69
+ :Driver License Category: AM A1 B1 B D BE DE
70
+ :Last Name: MARTIN
71
+ :First Name: PAUL
72
+ :Date Of Birth: 1981-07-14
73
+ :Place Of Birth: Utopiacity
74
+ :Expiry Date: 2018-12-31
75
+ :Issue Date: 2013-01-01
76
+ :Issue Authority: 99999UpiaCity
77
+ :MRZ: D1FRA13AA000026181231MARTIN<<9
78
+ :Address:
79
+ ```
80
+
81
+ # Field Types
82
+ ## Standard Fields
83
+ These fields are generic and used in several products.
84
+
85
+ ### Basic Field
86
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
87
+ A typical `Field` object will have the following attributes:
88
+
89
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
90
+ * **confidence** (Float, nil): the confidence score of the field prediction.
91
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
92
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
93
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
94
+ * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
95
+
96
+
97
+ 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.
98
+
99
+ ### Date Field
100
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
101
+
102
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
103
+
104
+
105
+ ### Position Field
106
+ 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:
107
+
108
+ * **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
109
+ * **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
110
+
111
+ ### String Field
112
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
113
+
114
+ ## Page-Level Fields
115
+ Some fields are constrained to the page level, and so will not be retrievable to through the document.
116
+
117
+ # Attributes
118
+ The following fields are extracted for Driver License V1:
119
+
120
+ ## Address
121
+ **address** ([StringField](#string-field)): EU driver license holders address
122
+
123
+ ```rb
124
+ puts result.document.inference.prediction.address.value
125
+ ```
126
+
127
+ ## Driver License Category
128
+ **category** ([StringField](#string-field)): EU driver license holders categories
129
+
130
+ ```rb
131
+ puts result.document.inference.prediction.category.value
132
+ ```
133
+
134
+ ## Country Code
135
+ **country_code** ([StringField](#string-field)): Country code extracted as a string.
136
+
137
+ ```rb
138
+ puts result.document.inference.prediction.country_code.value
139
+ ```
140
+
141
+ ## Date Of Birth
142
+ **date_of_birth** ([DateField](#date-field)): The date of birth of the document holder
143
+
144
+ ```rb
145
+ puts result.document.inference.prediction.date_of_birth.value
146
+ ```
147
+
148
+ ## Document ID
149
+ **document_id** ([StringField](#string-field)): ID number of the Document.
150
+
151
+ ```rb
152
+ puts result.document.inference.prediction.document_id.value
153
+ ```
154
+
155
+ ## Expiry Date
156
+ **expiry_date** ([DateField](#date-field)): Date the document expires
157
+
158
+ ```rb
159
+ puts result.document.inference.prediction.expiry_date.value
160
+ ```
161
+
162
+ ## First Name
163
+ **first_name** ([StringField](#string-field)): First name(s) of the driver license holder
164
+
165
+ ```rb
166
+ puts result.document.inference.prediction.first_name.value
167
+ ```
168
+
169
+ ## Issue Authority
170
+ **issue_authority** ([StringField](#string-field)): Authority that issued the document
171
+
172
+ ```rb
173
+ puts result.document.inference.prediction.issue_authority.value
174
+ ```
175
+
176
+ ## Issue Date
177
+ **issue_date** ([DateField](#date-field)): Date the document was issued
178
+
179
+ ```rb
180
+ puts result.document.inference.prediction.issue_date.value
181
+ ```
182
+
183
+ ## Last Name
184
+ **last_name** ([StringField](#string-field)): Last name of the driver license holder.
185
+
186
+ ```rb
187
+ puts result.document.inference.prediction.last_name.value
188
+ ```
189
+
190
+ ## MRZ
191
+ **mrz** ([StringField](#string-field)): Machine-readable license number
192
+
193
+ ```rb
194
+ puts result.document.inference.prediction.mrz.value
195
+ ```
196
+
197
+ ## Photo
198
+ [📄](#page-level-fields "This field is only present on individual pages.")**photo** ([PositionField](#position-field)): Has a photo of the EU driver license holder
199
+
200
+ ```rb
201
+ for photo_elem in result.document.photo do
202
+ puts photo_elem.polygon
203
+ end
204
+ ```
205
+
206
+ ## Place Of Birth
207
+ **place_of_birth** ([StringField](#string-field)): Place where the driver license holder was born
208
+
209
+ ```rb
210
+ puts result.document.inference.prediction.place_of_birth.value
211
+ ```
212
+
213
+ ## Signature
214
+ [📄](#page-level-fields "This field is only present on individual pages.")**signature** ([PositionField](#position-field)): Has a signature of the EU driver license holder
215
+
216
+ ```rb
217
+ for signature_elem in result.document.signature do
218
+ puts signature_elem.polygon
219
+ end
220
+ ```
221
+
222
+ # Questions?
223
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -303,4 +303,4 @@ puts result.document.inference.prediction.total_tax.value
303
303
  ```
304
304
 
305
305
  # Questions?
306
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
306
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -34,48 +34,52 @@ puts result.document
34
34
  ########
35
35
  Document
36
36
  ########
37
- :Mindee ID: 81c1d637-3a84-41d9-b40a-f72ca2a58826
37
+ :Mindee ID: a6b54e2d-a7fa-4e08-8de6-6cd296f50f3d
38
38
  :Filename: default_sample.jpg
39
39
 
40
40
  Inference
41
41
  #########
42
- :Product: mindee/financial_document v1.1
42
+ :Product: mindee/financial_document v1.2
43
43
  :Rotation applied: Yes
44
44
 
45
45
  Prediction
46
46
  ==========
47
47
  :Locale: en; en; USD;
48
- :Invoice Number:
49
- :Reference Numbers:
50
- :Purchase Date: 2014-07-07
51
- :Due Date: 2014-07-07
52
- :Total Net: 40.48
53
- :Total Amount: 53.82
48
+ :Invoice Number: INT-001
49
+ :Reference Numbers: 2412/2019
50
+ :Purchase Date: 2019-02-11
51
+ :Due Date: 2019-02-26
52
+ :Total Net: 195.00
53
+ :Total Amount: 204.75
54
54
  :Taxes:
55
55
  +---------------+--------+----------+---------------+
56
56
  | Base | Code | Rate (%) | Amount |
57
57
  +===============+========+==========+===============+
58
- | | TAX | | 3.34 |
58
+ | | | 5.00 | 9.75 |
59
59
  +---------------+--------+----------+---------------+
60
60
  :Supplier Payment Details:
61
- :Supplier Name: LOGANS
61
+ :Supplier Name: JOHN SMITH
62
62
  :Supplier Company Registrations:
63
- :Supplier Address: 2513 s stemmons freeway lewisville tx 75067
64
- :Supplier Phone Number: 9724596042
65
- :Customer Name:
63
+ :Supplier Address: 4490 Oak Drive Albany, NY 12210
64
+ :Supplier Phone Number:
65
+ :Customer Name: JESSIE M HORNE
66
66
  :Customer Company Registrations:
67
- :Customer Address:
68
- :Document Type: EXPENSE RECEIPT
69
- :Purchase Subcategory: restaurant
70
- :Purchase Category: food
71
- :Total Tax: 3.34
72
- :Tip and Gratuity: 10.00
73
- :Purchase Time: 20:20
67
+ :Customer Address: 2019 Redbud Drive New York, NY 10011
68
+ :Document Type: INVOICE
69
+ :Purchase Subcategory:
70
+ :Purchase Category: miscellaneous
71
+ :Total Tax: 9.75
72
+ :Tip and Gratuity:
73
+ :Purchase Time:
74
74
  :Line Items:
75
75
  +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
76
76
  | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
77
77
  +======================================+==============+==========+============+==============+==============+============+
78
- | TAX | | | | | 3.34 | |
78
+ | Front and rear brake cables | | 1.00 | | | 100.00 | 100.00 |
79
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
80
+ | New set of pedal arms | | 2.00 | | | 50.00 | 25.00 |
81
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
82
+ | Labon 3hrs | | 3.00 | | | 45.00 | 15.00 |
79
83
  +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
80
84
 
81
85
  Page Predictions
@@ -84,37 +88,41 @@ Page Predictions
84
88
  Page 0
85
89
  ------
86
90
  :Locale: en; en; USD;
87
- :Invoice Number:
88
- :Reference Numbers:
89
- :Purchase Date: 2014-07-07
90
- :Due Date: 2014-07-07
91
- :Total Net: 40.48
92
- :Total Amount: 53.82
91
+ :Invoice Number: INT-001
92
+ :Reference Numbers: 2412/2019
93
+ :Purchase Date: 2019-02-11
94
+ :Due Date: 2019-02-26
95
+ :Total Net: 195.00
96
+ :Total Amount: 204.75
93
97
  :Taxes:
94
98
  +---------------+--------+----------+---------------+
95
99
  | Base | Code | Rate (%) | Amount |
96
100
  +===============+========+==========+===============+
97
- | | TAX | | 3.34 |
101
+ | | | 5.00 | 9.75 |
98
102
  +---------------+--------+----------+---------------+
99
103
  :Supplier Payment Details:
100
- :Supplier Name: LOGANS
104
+ :Supplier Name: JOHN SMITH
101
105
  :Supplier Company Registrations:
102
- :Supplier Address: 2513 s stemmons freeway lewisville tx 75067
103
- :Supplier Phone Number: 9724596042
104
- :Customer Name:
106
+ :Supplier Address: 4490 Oak Drive Albany, NY 12210
107
+ :Supplier Phone Number:
108
+ :Customer Name: JESSIE M HORNE
105
109
  :Customer Company Registrations:
106
- :Customer Address:
107
- :Document Type: EXPENSE RECEIPT
108
- :Purchase Subcategory: restaurant
109
- :Purchase Category: food
110
- :Total Tax: 3.34
111
- :Tip and Gratuity: 10.00
112
- :Purchase Time: 20:20
110
+ :Customer Address: 2019 Redbud Drive New York, NY 10011
111
+ :Document Type: INVOICE
112
+ :Purchase Subcategory:
113
+ :Purchase Category: miscellaneous
114
+ :Total Tax: 9.75
115
+ :Tip and Gratuity:
116
+ :Purchase Time:
113
117
  :Line Items:
114
118
  +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
115
119
  | Description | Product code | Quantity | Tax Amount | Tax Rate (%) | Total Amount | Unit Price |
116
120
  +======================================+==============+==========+============+==============+==============+============+
117
- | TAX | | | | | 3.34 | |
121
+ | Front and rear brake cables | | 1.00 | | | 100.00 | 100.00 |
122
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
123
+ | New set of pedal arms | | 2.00 | | | 50.00 | 25.00 |
124
+ +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
125
+ | Labon 3hrs | | 3.00 | | | 45.00 | 15.00 |
118
126
  +--------------------------------------+--------------+----------+------------+--------------+--------------+------------+
119
127
  ```
120
128
 
@@ -384,4 +392,4 @@ puts result.document.inference.prediction.total_tax.value
384
392
  ```
385
393
 
386
394
  # Questions?
387
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
395
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -0,0 +1,90 @@
1
+ ---
2
+ title: Generated API Ruby
3
+ ---
4
+ The Ruby OCR SDK supports generated APIs.
5
+ Generated APIs can theoretically support all APIs in a catch-all generic format.
6
+
7
+ # Quick-Start
8
+
9
+ ```ruby
10
+ require 'mindee'
11
+
12
+ # Init a new client
13
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
14
+
15
+ # Load a file from disk
16
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
17
+
18
+ # Initialize a custom endpoint for this product
19
+ custom_endpoint = mindee_client.create_endpoint(
20
+ account_name: 'my-account',
21
+ endpoint_name: 'my-endpoint',
22
+ version: 'my-version'
23
+ )
24
+
25
+ # Parse the file
26
+ result = mindee_client.enqueue_and_parse(
27
+ input_source,
28
+ Mindee::Product::Generated::GeneratedV1,
29
+ endpoint: custom_endpoint
30
+ )
31
+
32
+ # Print a full summary of the parsed data in RST format
33
+ puts result.document
34
+ ```
35
+
36
+ # Generated Endpoints
37
+
38
+ You may have noticed in the previous step that in order to access a custom build, you will need to provide an account and an endpoint name at the very least.
39
+
40
+ Although it is optional, the version number should match the latest version of your build in most use-cases.
41
+ If it is not set, it will default to "1".
42
+
43
+ # Field Types
44
+
45
+ ## Generated Fields
46
+
47
+ ### Generated List Field
48
+
49
+ A `GeneratedListField` is a special type of custom list that implements the following:
50
+
51
+ - **values** (`Array<StringField`[GeneratedObjectField](#Generated-object-field)`>`): the confidence score of the field prediction.
52
+ - **page_id** (`Integer`): only available for some documents ATM.
53
+
54
+ Since the inner contents can vary, the value isn't accessed through a property, but rather through the following functions:
55
+
56
+ - **contents_list()** (`-> Array<String, Float>>`): returns a list of values for each element.
57
+ - **contents_string(separator=" ")** (`-> String`): returns a list of concatenated values, with an optional **separator** `String` between them.
58
+ > **Note:** the `to_s` method returns a string representation of all values of this object, with an empty space between each of them.
59
+
60
+ ### Generated Object Field
61
+
62
+ Unrecognized structures and sometimes values of `ListField`s are stored in a `GeneratedObjectField` structure, which is implemented dynamically depending on the object's structure.
63
+
64
+ - **page_id** (`[Integer, nil]`): the ID of the page, is `nil` when at document-level.
65
+ - **raw_value** (`[String, nil]`): an optional field for when some post-processing has been done on fields (e.g. amounts). `nil` in most instances.
66
+ - **confidence** (`[Float, nil]`): the confidence score of the field prediction. Warning: support isn't guaranteed on all APIs.
67
+
68
+
69
+ > **Other fields**:No matter what, other fields will be stored in a dictionary-like structure with a `key: value` pair where `key` is a string and `value` is a nullable string. They can be accessed like any other regular value, but won't be suggested by your IDE.
70
+
71
+
72
+ ### StringField
73
+ The text field `StringField` only has one constraint: its **value** is an `Optional[str]`.
74
+
75
+
76
+ # Attributes
77
+
78
+ Generated builds always have access to at least two attributes:
79
+
80
+ ## Fields
81
+
82
+ **fields** (`Hash<String, Array<`[GeneratedListField](#generated-list-field),[GeneratedObjectField](#generated-object-field), `(#stringfield)[StringField]>>`):
83
+
84
+ ```ruby
85
+ puts result.document.inference.prediction.fields["my-field"].to_s
86
+ ```
87
+
88
+ # Questions?
89
+
90
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -319,4 +319,4 @@ input_source = mindee_client.source_from_file(input_file, "name-of-my-file.ext",
319
319
  Note: This only works for local files, files sent by URL will not be processed.
320
320
 
321
321
  ## Questions?
322
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
322
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
data/docs/idcard_fr_v2.md CHANGED
@@ -250,4 +250,4 @@ puts result.document.inference.prediction.surname.value
250
250
  ```
251
251
 
252
252
  # Questions?
253
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
253
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -0,0 +1,195 @@
1
+ ---
2
+ title: International ID OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [International ID API](https://platform.mindee.com/mindee/international_id).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/international_id/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![International ID sample](https://github.com/mindee/client-lib-test-data/blob/main/products/international_id/default_sample.jpg?raw=true)
8
+
9
+ # Quick-Start
10
+ ```rb
11
+ require 'mindee'
12
+
13
+ # Init a new client
14
+ mindee_client = Mindee::Client.new(api_key: 'my-api-key')
15
+
16
+ # Load a file from disk
17
+ input_source = mindee_client.source_from_path('/path/to/the/file.ext')
18
+
19
+ # Parse the file
20
+ result = mindee_client.enqueue_and_parse(
21
+ input_source,
22
+ Mindee::Product::InternationalId::InternationalIdV2
23
+ )
24
+
25
+ # Print a full summary of the parsed data in RST format
26
+ puts result.document
27
+
28
+ # Print the document-level parsed data
29
+ # puts result.document.inference.prediction
30
+ ```
31
+
32
+ **Output (RST):**
33
+ ```rst
34
+ ```
35
+
36
+ # Field Types
37
+ ## Standard Fields
38
+ These fields are generic and used in several products.
39
+
40
+ ### Basic Field
41
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
42
+ A typical `Field` object will have the following attributes:
43
+
44
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
45
+ * **confidence** (Float, nil): the confidence score of the field prediction.
46
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
47
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
48
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
49
+ * **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
50
+
51
+
52
+ Aside from the previous attributes, all basic fields have access to a `to_s` method that can be used to print their value as a string.
53
+
54
+
55
+ ### Classification Field
56
+ The classification field `ClassificationField` does not implement all the basic `Field` attributes. It only implements **value**, **confidence** and **page_id**.
57
+
58
+ > Note: a classification field's `value is always a `String`.
59
+
60
+ ### Date Field
61
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
62
+
63
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
64
+
65
+ ### String Field
66
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
67
+
68
+ # Attributes
69
+ The following fields are extracted for International ID V2:
70
+
71
+ ## Address
72
+ **address** ([StringField](#string-field)): The physical address of the document holder.
73
+
74
+ ```rb
75
+ puts result.document.inference.prediction.address.value
76
+ ```
77
+
78
+ ## Birth Date
79
+ **birth_date** ([DateField](#date-field)): The date of birth of the document holder.
80
+
81
+ ```rb
82
+ puts result.document.inference.prediction.birth_date.value
83
+ ```
84
+
85
+ ## Birth Place
86
+ **birth_place** ([StringField](#string-field)): The place of birth of the document holder.
87
+
88
+ ```rb
89
+ puts result.document.inference.prediction.birth_place.value
90
+ ```
91
+
92
+ ## Country of Issue
93
+ **country_of_issue** ([StringField](#string-field)): The country where the document was issued.
94
+
95
+ ```rb
96
+ puts result.document.inference.prediction.country_of_issue.value
97
+ ```
98
+
99
+ ## Document Number
100
+ **document_number** ([StringField](#string-field)): The unique identifier assigned to the document.
101
+
102
+ ```rb
103
+ puts result.document.inference.prediction.document_number.value
104
+ ```
105
+
106
+ ## Document Type
107
+ **document_type** ([ClassificationField](#classification-field)): The type of personal identification document.
108
+
109
+ ```rb
110
+ puts result.document.inference.prediction.document_type.value
111
+ ```
112
+
113
+ ## Expiration Date
114
+ **expiry_date** ([DateField](#date-field)): The date when the document becomes invalid.
115
+
116
+ ```rb
117
+ puts result.document.inference.prediction.expiry_date.value
118
+ ```
119
+
120
+ ## Given Names
121
+ **given_names** (Array<[StringField](#string-field)>): The list of the document holder's given names.
122
+
123
+ ```rb
124
+ for given_names_elem in result.document.inference.prediction.given_names do
125
+ puts given_names_elem.value
126
+ end
127
+ ```
128
+
129
+ ## Issue Date
130
+ **issue_date** ([DateField](#date-field)): The date when the document was issued.
131
+
132
+ ```rb
133
+ puts result.document.inference.prediction.issue_date.value
134
+ ```
135
+
136
+ ## MRZ Line 1
137
+ **mrz_line1** ([StringField](#string-field)): The Machine Readable Zone, first line.
138
+
139
+ ```rb
140
+ puts result.document.inference.prediction.mrz_line1.value
141
+ ```
142
+
143
+ ## MRZ Line 2
144
+ **mrz_line2** ([StringField](#string-field)): The Machine Readable Zone, second line.
145
+
146
+ ```rb
147
+ puts result.document.inference.prediction.mrz_line2.value
148
+ ```
149
+
150
+ ## MRZ Line 3
151
+ **mrz_line3** ([StringField](#string-field)): The Machine Readable Zone, third line.
152
+
153
+ ```rb
154
+ puts result.document.inference.prediction.mrz_line3.value
155
+ ```
156
+
157
+ ## Nationality
158
+ **nationality** ([StringField](#string-field)): The country of citizenship of the document holder.
159
+
160
+ ```rb
161
+ puts result.document.inference.prediction.nationality.value
162
+ ```
163
+
164
+ ## Personal Number
165
+ **personal_number** ([StringField](#string-field)): The unique identifier assigned to the document holder.
166
+
167
+ ```rb
168
+ puts result.document.inference.prediction.personal_number.value
169
+ ```
170
+
171
+ ## Sex
172
+ **sex** ([StringField](#string-field)): The biological sex of the document holder.
173
+
174
+ ```rb
175
+ puts result.document.inference.prediction.sex.value
176
+ ```
177
+
178
+ ## State of Issue
179
+ **state_of_issue** ([StringField](#string-field)): The state or territory where the document was issued.
180
+
181
+ ```rb
182
+ puts result.document.inference.prediction.state_of_issue.value
183
+ ```
184
+
185
+ ## Surnames
186
+ **surnames** (Array<[StringField](#string-field)>): The list of the document holder's family names.
187
+
188
+ ```rb
189
+ for surnames_elem in result.document.inference.prediction.surnames do
190
+ puts surnames_elem.value
191
+ end
192
+ ```
193
+
194
+ # Questions?
195
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
@@ -82,4 +82,4 @@ end
82
82
  ```
83
83
 
84
84
  # Questions?
85
- [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
85
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)