mindee 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +57 -7
  4. data/bin/mindee.rb +160 -83
  5. data/docs/bank_account_details_v2.md +137 -0
  6. data/docs/bank_check_v1.md +179 -0
  7. data/docs/barcode_reader_v1.md +104 -0
  8. data/docs/carte_vitale_v1.md +123 -0
  9. data/docs/code_samples/barcode_reader_v1.txt +19 -0
  10. data/docs/code_samples/cropper_v1.txt +16 -0
  11. data/docs/code_samples/idcard_fr_v2.txt +19 -0
  12. data/docs/code_samples/invoice_splitter_v1_async.txt +6 -54
  13. data/docs/code_samples/multi_receipts_detector_v1.txt +19 -0
  14. data/docs/code_samples/us_w9_v1.txt +16 -0
  15. data/docs/cropper_v1.md +97 -0
  16. data/docs/custom_v1.md +101 -0
  17. data/docs/expense_receipts_v5.md +306 -0
  18. data/docs/financial_document_v1.md +384 -0
  19. data/docs/{ruby-getting-started.md → getting_started.md} +22 -6
  20. data/docs/idcard_fr_v2.md +253 -0
  21. data/docs/invoice_splitter_v1.md +85 -0
  22. data/docs/invoices_v4.md +369 -0
  23. data/docs/license_plates_v1.md +91 -0
  24. data/docs/multi_receipts_detector_v1.md +105 -0
  25. data/docs/passport_v1.md +186 -0
  26. data/docs/proof_of_address_v1.md +207 -0
  27. data/docs/us_driver_license_v1.md +268 -0
  28. data/docs/us_w9_v1.md +207 -0
  29. data/lib/mindee/client.rb +95 -16
  30. data/lib/mindee/geometry/quadrilateral.rb +5 -0
  31. data/lib/mindee/http/.rubocop.yml +8 -0
  32. data/lib/mindee/http/endpoint.rb +14 -6
  33. data/lib/mindee/http/error.rb +104 -0
  34. data/lib/mindee/http.rb +1 -0
  35. data/lib/mindee/input/sources.rb +84 -15
  36. data/lib/mindee/parsing/common/api_response.rb +11 -1
  37. data/lib/mindee/parsing/common/inference.rb +2 -2
  38. data/lib/mindee/parsing/common/ocr/ocr.rb +1 -0
  39. data/lib/mindee/parsing/common.rb +0 -1
  40. data/lib/mindee/parsing/standard/company_registration_field.rb +1 -1
  41. data/lib/mindee/parsing/standard/locale_field.rb +1 -1
  42. data/lib/mindee/parsing/standard/payment_details_field.rb +1 -1
  43. data/lib/mindee/parsing/standard/position_field.rb +10 -3
  44. data/lib/mindee/parsing/standard/{text_field.rb → string_field.rb} +1 -1
  45. data/lib/mindee/parsing/standard.rb +1 -1
  46. data/lib/mindee/pdf/pdf_processing.rb +2 -1
  47. data/lib/mindee/product/barcode_reader/barcode_reader_v1.rb +37 -0
  48. data/lib/mindee/product/barcode_reader/barcode_reader_v1_document.rb +44 -0
  49. data/lib/mindee/product/barcode_reader/barcode_reader_v1_page.rb +32 -0
  50. data/lib/mindee/product/cropper/cropper_v1.rb +37 -0
  51. data/lib/mindee/product/cropper/cropper_v1_document.rb +13 -0
  52. data/lib/mindee/product/cropper/cropper_v1_page.rb +49 -0
  53. data/lib/mindee/product/custom/custom_v1.rb +1 -0
  54. data/lib/mindee/product/eu/license_plate/license_plate_v1.rb +1 -0
  55. data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +2 -2
  56. data/lib/mindee/product/financial_document/financial_document_v1.rb +1 -0
  57. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +24 -24
  58. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1.rb +1 -0
  59. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v1_document.rb +6 -6
  60. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2.rb +1 -0
  61. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_document.rb +6 -6
  62. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1.rb +1 -0
  63. data/lib/mindee/product/fr/carte_vitale/carte_vitale_v1_document.rb +6 -6
  64. data/lib/mindee/product/fr/id_card/id_card_v1.rb +1 -0
  65. data/lib/mindee/product/fr/id_card/id_card_v1_document.rb +16 -16
  66. data/lib/mindee/product/fr/id_card/id_card_v2.rb +39 -0
  67. data/lib/mindee/product/fr/id_card/id_card_v2_document.rb +107 -0
  68. data/lib/mindee/product/fr/id_card/id_card_v2_page.rb +53 -0
  69. data/lib/mindee/product/invoice/invoice_v4.rb +1 -0
  70. data/lib/mindee/product/invoice/invoice_v4_document.rb +24 -24
  71. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +1 -0
  72. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +5 -3
  73. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1.rb +37 -0
  74. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +35 -0
  75. data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +32 -0
  76. data/lib/mindee/product/passport/passport_v1.rb +1 -0
  77. data/lib/mindee/product/passport/passport_v1_document.rb +16 -16
  78. data/lib/mindee/product/proof_of_address/proof_of_address_v1.rb +1 -0
  79. data/lib/mindee/product/proof_of_address/proof_of_address_v1_document.rb +14 -14
  80. data/lib/mindee/product/receipt/receipt_v4_document.rb +6 -6
  81. data/lib/mindee/product/receipt/receipt_v5.rb +1 -0
  82. data/lib/mindee/product/receipt/receipt_v5_document.rb +12 -12
  83. data/lib/mindee/product/us/bank_check/bank_check_v1.rb +1 -0
  84. data/lib/mindee/product/us/bank_check/bank_check_v1_document.rb +8 -8
  85. data/lib/mindee/product/us/driver_license/driver_license_v1.rb +1 -0
  86. data/lib/mindee/product/us/driver_license/driver_license_v1_document.rb +28 -28
  87. data/lib/mindee/product/us/w9/w9_v1.rb +39 -0
  88. data/lib/mindee/product/us/w9/w9_v1_document.rb +15 -0
  89. data/lib/mindee/product/us/w9/w9_v1_page.rb +102 -0
  90. data/lib/mindee/product.rb +5 -0
  91. data/lib/mindee/version.rb +5 -1
  92. data/lib/mindee.rb +47 -0
  93. metadata +43 -9
  94. data/docs/ruby-api-builder.md +0 -123
  95. data/docs/ruby-invoice-ocr.md +0 -271
  96. data/docs/ruby-passport-ocr.md +0 -165
  97. data/docs/ruby-receipt-ocr.md +0 -196
  98. data/lib/mindee/parsing/common/error.rb +0 -24
@@ -0,0 +1,186 @@
1
+ ---
2
+ title: Passport OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Passport API](https://platform.mindee.com/mindee/passport).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/passport/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Passport sample](https://github.com/mindee/client-lib-test-data/blob/main/products/passport/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::Passport::PassportV1
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: 18e41f6c-16cd-4f8e-8cd2-00ca02a35764
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/passport v1.0
43
+ :Rotation applied: Yes
44
+
45
+ Prediction
46
+ ==========
47
+ :Country Code: GBR
48
+ :ID Number: 707797979
49
+ :Given Name(s): HENERT
50
+ :Surname: PUDARSAN
51
+ :Date of Birth: 1995-05-20
52
+ :Place of Birth: CAMTETH
53
+ :Gender: M
54
+ :Date of Issue: 2012-04-22
55
+ :Expiry Date: 2017-04-22
56
+ :MRZ Line 1: P<GBRPUDARSAN<<HENERT<<<<<<<<<<<<<<<<<<<<<<<
57
+ :MRZ Line 2: 7077979792GBR9505209M1704224<<<<<<<<<<<<<<00
58
+
59
+ Page Predictions
60
+ ================
61
+
62
+ Page 0
63
+ ------
64
+ :Country Code: GBR
65
+ :ID Number: 707797979
66
+ :Given Name(s): HENERT
67
+ :Surname: PUDARSAN
68
+ :Date of Birth: 1995-05-20
69
+ :Place of Birth: CAMTETH
70
+ :Gender: M
71
+ :Date of Issue: 2012-04-22
72
+ :Expiry Date: 2017-04-22
73
+ :MRZ Line 1: P<GBRPUDARSAN<<HENERT<<<<<<<<<<<<<<<<<<<<<<<
74
+ :MRZ Line 2: 7077979792GBR9505209M1704224<<<<<<<<<<<<<<00
75
+ ```
76
+
77
+ # Field Types
78
+ ## Standard Fields
79
+ These fields are generic and used in several products.
80
+
81
+ ### Basic Field
82
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
83
+ A typical `Field` object will have the following attributes:
84
+
85
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
86
+ * **confidence** (Float, nil): the confidence score of the field prediction.
87
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
88
+ * **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.
90
+ * **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
91
+
92
+
93
+ 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.
94
+
95
+ ### Date Field
96
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
97
+
98
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
99
+
100
+ ### String Field
101
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
102
+
103
+ # Attributes
104
+ The following fields are extracted for Passport V1:
105
+
106
+ ## Date of Birth
107
+ **birth_date** ([DateField](#date-field)): The date of birth of the passport holder.
108
+
109
+ ```rb
110
+ puts result.document.inference.prediction.birth_date.value
111
+ ```
112
+
113
+ ## Place of Birth
114
+ **birth_place** ([StringField](#string-field)): The place of birth of the passport holder.
115
+
116
+ ```rb
117
+ puts result.document.inference.prediction.birth_place.value
118
+ ```
119
+
120
+ ## Country Code
121
+ **country** ([StringField](#string-field)): The country's 3 letter code (ISO 3166-1 alpha-3).
122
+
123
+ ```rb
124
+ puts result.document.inference.prediction.country.value
125
+ ```
126
+
127
+ ## Expiry Date
128
+ **expiry_date** ([DateField](#date-field)): The expiry date of the passport.
129
+
130
+ ```rb
131
+ puts result.document.inference.prediction.expiry_date.value
132
+ ```
133
+
134
+ ## Gender
135
+ **gender** ([StringField](#string-field)): The gender of the passport holder.
136
+
137
+ ```rb
138
+ puts result.document.inference.prediction.gender.value
139
+ ```
140
+
141
+ ## Given Name(s)
142
+ **given_names** (Array<[StringField](#string-field)>): The given name(s) of the passport holder.
143
+
144
+ ```rb
145
+ for given_names_elem in result.document.inference.prediction.given_names do
146
+ puts given_names_elem.value
147
+ end
148
+ ```
149
+
150
+ ## ID Number
151
+ **id_number** ([StringField](#string-field)): The passport's identification number.
152
+
153
+ ```rb
154
+ puts result.document.inference.prediction.id_number.value
155
+ ```
156
+
157
+ ## Date of Issue
158
+ **issuance_date** ([DateField](#date-field)): The date the passport was issued.
159
+
160
+ ```rb
161
+ puts result.document.inference.prediction.issuance_date.value
162
+ ```
163
+
164
+ ## MRZ Line 1
165
+ **mrz1** ([StringField](#string-field)): Machine Readable Zone, first line
166
+
167
+ ```rb
168
+ puts result.document.inference.prediction.mrz1.value
169
+ ```
170
+
171
+ ## MRZ Line 2
172
+ **mrz2** ([StringField](#string-field)): Machine Readable Zone, second line
173
+
174
+ ```rb
175
+ puts result.document.inference.prediction.mrz2.value
176
+ ```
177
+
178
+ ## Surname
179
+ **surname** ([StringField](#string-field)): The surname of the passport holder.
180
+
181
+ ```rb
182
+ puts result.document.inference.prediction.surname.value
183
+ ```
184
+
185
+ # Questions?
186
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
@@ -0,0 +1,207 @@
1
+ ---
2
+ title: Proof of Address OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Proof of Address API](https://platform.mindee.com/mindee/proof_of_address).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
7
+ ![Proof of Address sample](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/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::ProofOfAddress::ProofOfAddressV1
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: 3a7e1da6-d4d0-4704-af91-051fe5484c2e
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/proof_of_address v1.0
43
+ :Rotation applied: Yes
44
+
45
+ Prediction
46
+ ==========
47
+ :Locale: en; en; USD;
48
+ :Issuer Name: PPL ELECTRIC UTILITIES
49
+ :Issuer Company Registrations:
50
+ :Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN,PA 18101-1175
51
+ :Recipient Name:
52
+ :Recipient Company Registrations:
53
+ :Recipient Address: 123 MAIN ST ANYTOWN,PA 18062
54
+ :Dates: 2011-07-27
55
+ 2011-07-06
56
+ 2011-08-03
57
+ 2011-07-27
58
+ 2011-06-01
59
+ 2011-07-01
60
+ 2010-07-01
61
+ 2010-08-01
62
+ 2011-07-01
63
+ 2009-08-01
64
+ 2010-07-01
65
+ 2011-07-27
66
+ :Date of Issue: 2011-07-27
67
+
68
+ Page Predictions
69
+ ================
70
+
71
+ Page 0
72
+ ------
73
+ :Locale: en; en; USD;
74
+ :Issuer Name: PPL ELECTRIC UTILITIES
75
+ :Issuer Company Registrations:
76
+ :Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN,PA 18101-1175
77
+ :Recipient Name:
78
+ :Recipient Company Registrations:
79
+ :Recipient Address: 123 MAIN ST ANYTOWN,PA 18062
80
+ :Dates: 2011-07-27
81
+ 2011-07-06
82
+ 2011-08-03
83
+ 2011-07-27
84
+ 2011-06-01
85
+ 2011-07-01
86
+ 2010-07-01
87
+ 2010-08-01
88
+ 2011-07-01
89
+ 2009-08-01
90
+ 2010-07-01
91
+ 2011-07-27
92
+ :Date of Issue: 2011-07-27
93
+ ```
94
+
95
+ # Field Types
96
+ ## Standard Fields
97
+ These fields are generic and used in several products.
98
+
99
+ ### Basic Field
100
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
101
+ A typical `Field` object will have the following attributes:
102
+
103
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
104
+ * **confidence** (Float, nil): the confidence score of the field prediction.
105
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
106
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
107
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
108
+ * **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
109
+
110
+
111
+ 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.
112
+
113
+
114
+ ### Company Registration Field
115
+ Aside from the basic `Field` attributes, the company registration field `CompanyRegistrationField` also implements the following:
116
+
117
+ * **type** (`String`): the type of company.
118
+
119
+ ### Date Field
120
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
121
+
122
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
123
+
124
+ ### Locale Field
125
+ The locale field `LocaleField` only implements the **value**, **confidence** and **page_id** base `Field` attributes, but it comes with its own:
126
+
127
+ * **language** (`String`): ISO 639-1 language code (e.g.: `en` for English). Can be `nil`.
128
+ * **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`.
129
+ * **currency** (`String`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `nil`.
130
+
131
+ ### String Field
132
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
133
+
134
+ # Attributes
135
+ The following fields are extracted for Proof of Address V1:
136
+
137
+ ## Date of Issue
138
+ **date** ([DateField](#date-field)): The date the document was issued.
139
+
140
+ ```rb
141
+ puts result.document.inference.prediction.date.value
142
+ ```
143
+
144
+ ## Dates
145
+ **dates** (Array<[DateField](#date-field)>): List of dates found on the document.
146
+
147
+ ```rb
148
+ for dates_elem in result.document.inference.prediction.dates do
149
+ puts dates_elem.value
150
+ end
151
+ ```
152
+
153
+ ## Issuer Address
154
+ **issuer_address** ([StringField](#string-field)): The address of the document's issuer.
155
+
156
+ ```rb
157
+ puts result.document.inference.prediction.issuer_address.value
158
+ ```
159
+
160
+ ## Issuer Company Registrations
161
+ **issuer_company_registration** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations found for the issuer.
162
+
163
+ ```rb
164
+ for issuer_company_registration_elem in result.document.inference.prediction.issuer_company_registration do
165
+ puts issuer_company_registration_elem.value
166
+ end
167
+ ```
168
+
169
+ ## Issuer Name
170
+ **issuer_name** ([StringField](#string-field)): The name of the person or company issuing the document.
171
+
172
+ ```rb
173
+ puts result.document.inference.prediction.issuer_name.value
174
+ ```
175
+
176
+ ## Locale
177
+ **locale** ([LocaleField](#locale-field)): The locale detected on the document.
178
+
179
+ ```rb
180
+ puts result.document.inference.prediction.locale.value
181
+ ```
182
+
183
+ ## Recipient Address
184
+ **recipient_address** ([StringField](#string-field)): The address of the recipient.
185
+
186
+ ```rb
187
+ puts result.document.inference.prediction.recipient_address.value
188
+ ```
189
+
190
+ ## Recipient Company Registrations
191
+ **recipient_company_registration** (Array<[CompanyRegistrationField](#company-registration-field)>): List of company registrations found for the recipient.
192
+
193
+ ```rb
194
+ for recipient_company_registration_elem in result.document.inference.prediction.recipient_company_registration do
195
+ puts recipient_company_registration_elem.value
196
+ end
197
+ ```
198
+
199
+ ## Recipient Name
200
+ **recipient_name** ([StringField](#string-field)): The name of the person or company receiving the document.
201
+
202
+ ```rb
203
+ puts result.document.inference.prediction.recipient_name.value
204
+ ```
205
+
206
+ # Questions?
207
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)
@@ -0,0 +1,268 @@
1
+ ---
2
+ title: US Driver License OCR Ruby
3
+ ---
4
+ The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/us_driver_license).
5
+
6
+ Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_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/us_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::US::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: bf70068d-d3d6-49dc-b93a-b4b7d156fc3d
38
+ :Filename: default_sample.jpg
39
+
40
+ Inference
41
+ #########
42
+ :Product: mindee/us_driver_license v1.0
43
+ :Rotation applied: Yes
44
+
45
+ Prediction
46
+ ==========
47
+ :State: AZ
48
+ :Driver License ID: D12345678
49
+ :Expiry Date: 2018-02-01
50
+ :Date Of Issue: 2013-01-10
51
+ :Last Name: SAMPLE
52
+ :First Name: JELANI
53
+ :Address: 123 MAIN STREET PHOENIX AZ 85007
54
+ :Date Of Birth: 1957-02-01
55
+ :Restrictions: NONE
56
+ :Endorsements: NONE
57
+ :Class:
58
+ :Sex: M
59
+ :Height: 5-08
60
+ :Weight: 185
61
+ :Hair Color: BRO
62
+ :Eye Color: BRO
63
+ :Document Discriminator: 1234567890123456
64
+
65
+ Page Predictions
66
+ ================
67
+
68
+ Page 0
69
+ ------
70
+ :Photo: Polygon with 4 points.
71
+ :Signature: Polygon with 4 points.
72
+ :State: AZ
73
+ :Driver License ID: D12345678
74
+ :Expiry Date: 2018-02-01
75
+ :Date Of Issue: 2013-01-10
76
+ :Last Name: SAMPLE
77
+ :First Name: JELANI
78
+ :Address: 123 MAIN STREET PHOENIX AZ 85007
79
+ :Date Of Birth: 1957-02-01
80
+ :Restrictions: NONE
81
+ :Endorsements: NONE
82
+ :Class:
83
+ :Sex: M
84
+ :Height: 5-08
85
+ :Weight: 185
86
+ :Hair Color: BRO
87
+ :Eye Color: BRO
88
+ :Document Discriminator: 1234567890123456
89
+ ```
90
+
91
+ # Field Types
92
+ ## Standard Fields
93
+ These fields are generic and used in several products.
94
+
95
+ ### Basic Field
96
+ Each prediction object contains a set of fields that inherit from the generic `Field` class.
97
+ A typical `Field` object will have the following attributes:
98
+
99
+ * **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
100
+ * **confidence** (Float, nil): the confidence score of the field prediction.
101
+ * **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
102
+ * **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
103
+ * **page_id** (`Integer`, `nil`): the ID of the page, is `nil` when at document-level.
104
+ * **reconstructed** (`Boolean`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
105
+
106
+
107
+ 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.
108
+
109
+ ### Date Field
110
+ Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
111
+
112
+ * **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
113
+
114
+
115
+ ### Position Field
116
+ 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:
117
+
118
+ * **rectangle** (`Mindee::Geometry::Quadrilateral`): a Polygon with four points that may be oriented (even beyond canvas).
119
+ * **quadrangle** (`Mindee::Geometry::Quadrilateral`): a free polygon made up of four points.
120
+
121
+ ### String Field
122
+ The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
123
+
124
+ ## Page-Level Fields
125
+ Some fields are constrained to the page level, and so will not be retrievable to through the document.
126
+
127
+ # Attributes
128
+ The following fields are extracted for Driver License V1:
129
+
130
+ ## Address
131
+ **address** ([StringField](#string-field)): US driver license holders address
132
+
133
+ ```rb
134
+ puts result.document.inference.prediction.address.value
135
+ ```
136
+
137
+ ## Date Of Birth
138
+ **date_of_birth** ([DateField](#date-field)): US driver license holders date of birth
139
+
140
+ ```rb
141
+ puts result.document.inference.prediction.date_of_birth.value
142
+ ```
143
+
144
+ ## Document Discriminator
145
+ **dd_number** ([StringField](#string-field)): Document Discriminator Number of the US Driver License
146
+
147
+ ```rb
148
+ puts result.document.inference.prediction.dd_number.value
149
+ ```
150
+
151
+ ## Driver License Class
152
+ **dl_class** ([StringField](#string-field)): US driver license holders class
153
+
154
+ ```rb
155
+ puts result.document.inference.prediction.dl_class.value
156
+ ```
157
+
158
+ ## Driver License ID
159
+ **driver_license_id** ([StringField](#string-field)): ID number of the US Driver License.
160
+
161
+ ```rb
162
+ puts result.document.inference.prediction.driver_license_id.value
163
+ ```
164
+
165
+ ## Endorsements
166
+ **endorsements** ([StringField](#string-field)): US driver license holders endorsements
167
+
168
+ ```rb
169
+ puts result.document.inference.prediction.endorsements.value
170
+ ```
171
+
172
+ ## Expiry Date
173
+ **expiry_date** ([DateField](#date-field)): Date on which the documents expires.
174
+
175
+ ```rb
176
+ puts result.document.inference.prediction.expiry_date.value
177
+ ```
178
+
179
+ ## Eye Color
180
+ **eye_color** ([StringField](#string-field)): US driver license holders eye colour
181
+
182
+ ```rb
183
+ puts result.document.inference.prediction.eye_color.value
184
+ ```
185
+
186
+ ## First Name
187
+ **first_name** ([StringField](#string-field)): US driver license holders first name(s)
188
+
189
+ ```rb
190
+ puts result.document.inference.prediction.first_name.value
191
+ ```
192
+
193
+ ## Hair Color
194
+ **hair_color** ([StringField](#string-field)): US driver license holders hair colour
195
+
196
+ ```rb
197
+ puts result.document.inference.prediction.hair_color.value
198
+ ```
199
+
200
+ ## Height
201
+ **height** ([StringField](#string-field)): US driver license holders hight
202
+
203
+ ```rb
204
+ puts result.document.inference.prediction.height.value
205
+ ```
206
+
207
+ ## Date Of Issue
208
+ **issued_date** ([DateField](#date-field)): Date on which the documents was issued.
209
+
210
+ ```rb
211
+ puts result.document.inference.prediction.issued_date.value
212
+ ```
213
+
214
+ ## Last Name
215
+ **last_name** ([StringField](#string-field)): US driver license holders last name
216
+
217
+ ```rb
218
+ puts result.document.inference.prediction.last_name.value
219
+ ```
220
+
221
+ ## Photo
222
+ [📄](#page-level-fields "This field is only present on individual pages.")**photo** ([PositionField](#position-field)): Has a photo of the US driver license holder
223
+
224
+ ```rb
225
+ for photo_elem in result.document.photo do
226
+ puts photo_elem.polygon
227
+ end
228
+ ```
229
+
230
+ ## Restrictions
231
+ **restrictions** ([StringField](#string-field)): US driver license holders restrictions
232
+
233
+ ```rb
234
+ puts result.document.inference.prediction.restrictions.value
235
+ ```
236
+
237
+ ## Sex
238
+ **sex** ([StringField](#string-field)): US driver license holders gender
239
+
240
+ ```rb
241
+ puts result.document.inference.prediction.sex.value
242
+ ```
243
+
244
+ ## Signature
245
+ [📄](#page-level-fields "This field is only present on individual pages.")**signature** ([PositionField](#position-field)): Has a signature of the US driver license holder
246
+
247
+ ```rb
248
+ for signature_elem in result.document.signature do
249
+ puts signature_elem.polygon
250
+ end
251
+ ```
252
+
253
+ ## State
254
+ **state** ([StringField](#string-field)): US State
255
+
256
+ ```rb
257
+ puts result.document.inference.prediction.state.value
258
+ ```
259
+
260
+ ## Weight
261
+ **weight** ([StringField](#string-field)): US driver license holders weight
262
+
263
+ ```rb
264
+ puts result.document.inference.prediction.weight.value
265
+ ```
266
+
267
+ # Questions?
268
+ [Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)