Skip to content

Commit 7a3abeb

Browse files
✨ add support for business cards, delivery notes, indian passport & update resume, invoice & findoc (#124)
1 parent b95cd9c commit 7a3abeb

31 files changed

+1316
-50
lines changed

docs/business_card_v1.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
title: Business Card OCR Ruby
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: ruby-business-card-ocr
5+
parentDoc: 6294d97ee723f1008d2ab28e
6+
---
7+
The Ruby OCR SDK supports the [Business Card API](https://platform.mindee.com/mindee/business_card).
8+
9+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
10+
![Business Card sample](https://github.com/mindee/client-lib-test-data/blob/main/products/business_card/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::BusinessCard::BusinessCardV1
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: 6f9a261f-7609-4687-9af0-46a45156566e
42+
:Filename: default_sample.jpg
43+
44+
Inference
45+
#########
46+
:Product: mindee/business_card v1.0
47+
:Rotation applied: Yes
48+
49+
Prediction
50+
==========
51+
:Firstname: Andrew
52+
:Lastname: Morin
53+
:Job Title: Founder & CEO
54+
:Company: RemoteGlobal
55+
:Email: amorin@remoteglobalconsulting.com
56+
:Phone Number: +14015555555
57+
:Mobile Number: +13015555555
58+
:Fax Number: +14015555556
59+
:Address: 178 Main Avenue, Providence, RI 02111
60+
:Website: www.remoteglobalconsulting.com
61+
:Social Media: https://www.linkedin.com/in/johndoe
62+
https://twitter.com/johndoe
63+
```
64+
65+
# Field Types
66+
## Standard Fields
67+
These fields are generic and used in several products.
68+
69+
### Basic Field
70+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
71+
A typical `Field` object will have the following attributes:
72+
73+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
74+
* **confidence** (Float, nil): the confidence score of the field prediction.
75+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
76+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
77+
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
78+
* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
79+
80+
81+
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.
82+
83+
### String Field
84+
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
85+
86+
# Attributes
87+
The following fields are extracted for Business Card V1:
88+
89+
## Address
90+
**address** ([StringField](#string-field)): The address of the person.
91+
92+
```rb
93+
puts result.document.inference.prediction.address.value
94+
```
95+
96+
## Company
97+
**company** ([StringField](#string-field)): The company the person works for.
98+
99+
```rb
100+
puts result.document.inference.prediction.company.value
101+
```
102+
103+
## Email
104+
**email** ([StringField](#string-field)): The email address of the person.
105+
106+
```rb
107+
puts result.document.inference.prediction.email.value
108+
```
109+
110+
## Fax Number
111+
**fax_number** ([StringField](#string-field)): The Fax number of the person.
112+
113+
```rb
114+
puts result.document.inference.prediction.fax_number.value
115+
```
116+
117+
## Firstname
118+
**firstname** ([StringField](#string-field)): The given name of the person.
119+
120+
```rb
121+
puts result.document.inference.prediction.firstname.value
122+
```
123+
124+
## Job Title
125+
**job_title** ([StringField](#string-field)): The job title of the person.
126+
127+
```rb
128+
puts result.document.inference.prediction.job_title.value
129+
```
130+
131+
## Lastname
132+
**lastname** ([StringField](#string-field)): The lastname of the person.
133+
134+
```rb
135+
puts result.document.inference.prediction.lastname.value
136+
```
137+
138+
## Mobile Number
139+
**mobile_number** ([StringField](#string-field)): The mobile number of the person.
140+
141+
```rb
142+
puts result.document.inference.prediction.mobile_number.value
143+
```
144+
145+
## Phone Number
146+
**phone_number** ([StringField](#string-field)): The phone number of the person.
147+
148+
```rb
149+
puts result.document.inference.prediction.phone_number.value
150+
```
151+
152+
## Social Media
153+
**social_media** (Array<[StringField](#string-field)>): The social media profiles of the person or company.
154+
155+
```rb
156+
for social_media_elem in result.document.inference.prediction.social_media do
157+
puts social_media_elem.value
158+
end
159+
```
160+
161+
## Website
162+
**website** ([StringField](#string-field)): The website of the person or company.
163+
164+
```rb
165+
puts result.document.inference.prediction.website.value
166+
```
167+
168+
# Questions?
169+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'mindee'
2+
3+
# Init a new client
4+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5+
6+
# Load a file from disk
7+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8+
9+
# Parse the file
10+
result = mindee_client.enqueue_and_parse(
11+
input_source,
12+
Mindee::Product::BusinessCard::BusinessCardV1
13+
)
14+
15+
# Print a full summary of the parsed data in RST format
16+
puts result.document
17+
18+
# Print the document-level parsed data
19+
# puts result.document.inference.prediction
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'mindee'
2+
3+
# Init a new client
4+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5+
6+
# Load a file from disk
7+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8+
9+
# Parse the file
10+
result = mindee_client.enqueue_and_parse(
11+
input_source,
12+
Mindee::Product::DeliveryNote::DeliveryNoteV1
13+
)
14+
15+
# Print a full summary of the parsed data in RST format
16+
puts result.document
17+
18+
# Print the document-level parsed data
19+
# puts result.document.inference.prediction
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'mindee'
2+
3+
# Init a new client
4+
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
5+
6+
# Load a file from disk
7+
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
8+
9+
# Parse the file
10+
result = mindee_client.enqueue_and_parse(
11+
input_source,
12+
Mindee::Product::IND::IndianPassport::IndianPassportV1
13+
)
14+
15+
# Print a full summary of the parsed data in RST format
16+
puts result.document
17+
18+
# Print the document-level parsed data
19+
# puts result.document.inference.prediction

docs/delivery_notes_v1.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Delivery note OCR Ruby
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: ruby-delivery-note-ocr
5+
parentDoc: 6294d97ee723f1008d2ab28e
6+
---
7+
The Ruby OCR SDK supports the [Delivery note API](https://platform.mindee.com/mindee/delivery_notes).
8+
9+
Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/delivery_notes/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK.
10+
![Delivery note sample](https://github.com/mindee/client-lib-test-data/blob/main/products/delivery_notes/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::DeliveryNote::DeliveryNoteV1
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: d5ead821-edec-4d31-a69a-cf3998d9a506
42+
:Filename: default_sample.jpg
43+
44+
Inference
45+
#########
46+
:Product: mindee/delivery_notes v1.0
47+
:Rotation applied: Yes
48+
49+
Prediction
50+
==========
51+
:Delivery Date: 2019-10-02
52+
:Delivery Number: INT-001
53+
:Supplier Name: John Smith
54+
:Supplier Address: 4490 Oak Drive, Albany, NY 12210
55+
:Customer Name: Jessie M Horne
56+
:Customer Address: 4312 Wood Road, New York, NY 10031
57+
:Total Amount: 204.75
58+
```
59+
60+
# Field Types
61+
## Standard Fields
62+
These fields are generic and used in several products.
63+
64+
### Basic Field
65+
Each prediction object contains a set of fields that inherit from the generic `Field` class.
66+
A typical `Field` object will have the following attributes:
67+
68+
* **value** (`String`, `Float`, `Integer`, `Boolean`): corresponds to the field value. Can be `nil` if no value was extracted.
69+
* **confidence** (Float, nil): the confidence score of the field prediction.
70+
* **bounding_box** (`Mindee::Geometry::Quadrilateral`, `nil`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
71+
* **polygon** (`Mindee::Geometry::Polygon`, `nil`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
72+
* **page_id** (`Integer`, `nil`): the ID of the page, always `nil` when at document-level.
73+
* **reconstructed** (`Boolean`): indicates whether an object was reconstructed (not extracted as the API gave it).
74+
75+
76+
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.
77+
78+
79+
### Amount Field
80+
The amount field `AmountField` only has one constraint: its **value** is a `Float` (or `nil`).
81+
82+
### Date Field
83+
Aside from the basic `Field` attributes, the date field `DateField` also implements the following:
84+
85+
* **date_object** (`Date`): an accessible representation of the value as a JavaScript object.
86+
87+
### String Field
88+
The text field `StringField` only has one constraint: it's **value** is a `String` (or `nil`).
89+
90+
# Attributes
91+
The following fields are extracted for Delivery note V1:
92+
93+
## Customer Address
94+
**customer_address** ([StringField](#string-field)): The address of the customer receiving the goods.
95+
96+
```rb
97+
puts result.document.inference.prediction.customer_address.value
98+
```
99+
100+
## Customer Name
101+
**customer_name** ([StringField](#string-field)): The name of the customer receiving the goods.
102+
103+
```rb
104+
puts result.document.inference.prediction.customer_name.value
105+
```
106+
107+
## Delivery Date
108+
**delivery_date** ([DateField](#date-field)): The date on which the delivery is scheduled to arrive.
109+
110+
```rb
111+
puts result.document.inference.prediction.delivery_date.value
112+
```
113+
114+
## Delivery Number
115+
**delivery_number** ([StringField](#string-field)): A unique identifier for the delivery note.
116+
117+
```rb
118+
puts result.document.inference.prediction.delivery_number.value
119+
```
120+
121+
## Supplier Address
122+
**supplier_address** ([StringField](#string-field)): The address of the supplier providing the goods.
123+
124+
```rb
125+
puts result.document.inference.prediction.supplier_address.value
126+
```
127+
128+
## Supplier Name
129+
**supplier_name** ([StringField](#string-field)): The name of the supplier providing the goods.
130+
131+
```rb
132+
puts result.document.inference.prediction.supplier_name.value
133+
```
134+
135+
## Total Amount
136+
**total_amount** ([AmountField](#amount-field)): The total monetary value of the goods being delivered.
137+
138+
```rb
139+
puts result.document.inference.prediction.total_amount.value
140+
```
141+
142+
# Questions?
143+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)

0 commit comments

Comments
 (0)