Skip to content

Commit fc807f1

Browse files
📝 fix eudl doc + add missing entry for international id v2 (#84)
1 parent edfd912 commit fc807f1

6 files changed

Lines changed: 205 additions & 10 deletions

File tree

docs/eu_driver_license_v1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: EU EU Driver License OCR Ruby
2+
title: EU Driver License OCR Ruby
33
---
4-
The Ruby OCR SDK supports the [EU Driver License API](https://platform.mindee.com/mindee/eu_driver_license).
4+
The Ruby OCR SDK supports the [Driver License API](https://platform.mindee.com/mindee/eu_driver_license).
55

66
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-
![EU Driver License sample](https://github.com/mindee/client-lib-test-data/blob/main/products/eu_driver_license/default_sample.jpg?raw=true)
7+
![Driver License sample](https://github.com/mindee/client-lib-test-data/blob/main/products/eu_driver_license/default_sample.jpg?raw=true)
88

99
# Quick-Start
1010
```rb
@@ -115,7 +115,7 @@ The text field `StringField` only has one constraint: it's **value** is a `Strin
115115
Some fields are constrained to the page level, and so will not be retrievable to through the document.
116116

117117
# Attributes
118-
The following fields are extracted for EU Driver License V1:
118+
The following fields are extracted for Driver License V1:
119119

120120
## Address
121121
**address** ([StringField](#string-field)): EU driver license holders address

docs/international_id_v2.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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-1jv6nawjq-FDgFcF2T5CmMmRpl9LLptw)

lib/mindee/product/eu/driver_license/driver_license_v1.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
module Mindee
88
module Product
99
module EU
10-
# EU Driver License module.
10+
# Driver License module.
1111
module DriverLicense
12-
# EU Driver License V1 prediction inference.
12+
# Driver License V1 prediction inference.
1313
class DriverLicenseV1 < Mindee::Parsing::Common::Inference
1414
@endpoint_name = 'eu_driver_license'
1515
@endpoint_version = '1'

lib/mindee/product/eu/driver_license/driver_license_v1_document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Mindee
66
module Product
77
module EU
88
module DriverLicense
9-
# EU Driver License V1 document prediction.
9+
# Driver License V1 document prediction.
1010
class DriverLicenseV1Document < Mindee::Parsing::Common::Prediction
1111
include Mindee::Parsing::Standard
1212
# EU driver license holders address

lib/mindee/product/eu/driver_license/driver_license_v1_page.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Mindee
77
module Product
88
module EU
99
module DriverLicense
10-
# EU Driver License V1 page.
10+
# Driver License V1 page.
1111
class DriverLicenseV1Page < Mindee::Parsing::Common::Page
1212
# @param prediction [Hash]
1313
def initialize(prediction)
@@ -19,7 +19,7 @@ def initialize(prediction)
1919
end
2020
end
2121

22-
# EU Driver License V1 page prediction.
22+
# Driver License V1 page prediction.
2323
class DriverLicenseV1PagePrediction < DriverLicenseV1Document
2424
include Mindee::Parsing::Standard
2525

spec/document/eu/driver_license_v1_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
DIR_EU_DRIVER_LICENSE_V1 = File.join(DATA_DIR, 'products', 'eu_driver_license', 'response_v1').freeze
1010

1111
describe Mindee::Product::EU::DriverLicense::DriverLicenseV1 do
12-
context 'A EU Driver License V1' do
12+
context 'A Driver License V1' do
1313
it 'should load an empty document prediction' do
1414
response = load_json(DIR_EU_DRIVER_LICENSE_V1, 'empty.json')
1515
inference = Mindee::Parsing::Common::Document.new(

0 commit comments

Comments
 (0)