Skip to content

Commit ea95dfd

Browse files
✨ add support for business cards, delivery notes, indian passport & update resume (#272)
1 parent 52f0f46 commit ea95dfd

35 files changed

+1401
-41
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from mindee import Client, product, AsyncPredictResponse
2+
3+
# Init a new client
4+
mindee_client = Client(api_key="my-api-key")
5+
6+
# Load a file from disk
7+
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
8+
9+
# Load a file from disk and enqueue it.
10+
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
11+
product.BusinessCardV1,
12+
input_doc,
13+
)
14+
15+
# Print a brief summary of the parsed data
16+
print(result.document)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from mindee import Client, product, AsyncPredictResponse
2+
3+
# Init a new client
4+
mindee_client = Client(api_key="my-api-key")
5+
6+
# Load a file from disk
7+
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
8+
9+
# Load a file from disk and enqueue it.
10+
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
11+
product.DeliveryNoteV1,
12+
input_doc,
13+
)
14+
15+
# Print a brief summary of the parsed data
16+
print(result.document)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from mindee import Client, product, AsyncPredictResponse
2+
3+
# Init a new client
4+
mindee_client = Client(api_key="my-api-key")
5+
6+
# Load a file from disk
7+
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
8+
9+
# Load a file from disk and enqueue it.
10+
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
11+
product.ind.IndianPassportV1,
12+
input_doc,
13+
)
14+
15+
# Print a brief summary of the parsed data
16+
print(result.document)

docs/extras/guide/business_card_v1.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: Business Card OCR Python
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: python-business-card-ocr
5+
parentDoc: 609808f773b0b90051d839de
6+
---
7+
The Python 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+
```py
14+
from mindee import Client, product, AsyncPredictResponse
15+
16+
# Init a new client
17+
mindee_client = Client(api_key="my-api-key")
18+
19+
# Load a file from disk
20+
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
21+
22+
# Load a file from disk and enqueue it.
23+
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
24+
product.BusinessCardV1,
25+
input_doc,
26+
)
27+
28+
# Print a brief summary of the parsed data
29+
print(result.document)
30+
31+
```
32+
33+
**Output (RST):**
34+
```rst
35+
########
36+
Document
37+
########
38+
:Mindee ID: 6f9a261f-7609-4687-9af0-46a45156566e
39+
:Filename: default_sample.jpg
40+
41+
Inference
42+
#########
43+
:Product: mindee/business_card v1.0
44+
:Rotation applied: Yes
45+
46+
Prediction
47+
==========
48+
:Firstname: Andrew
49+
:Lastname: Morin
50+
:Job Title: Founder & CEO
51+
:Company: RemoteGlobal
52+
:Email: amorin@remoteglobalconsulting.com
53+
:Phone Number: +14015555555
54+
:Mobile Number: +13015555555
55+
:Fax Number: +14015555556
56+
:Address: 178 Main Avenue, Providence, RI 02111
57+
:Website: www.remoteglobalconsulting.com
58+
:Social Media: https://www.linkedin.com/in/johndoe
59+
https://twitter.com/johndoe
60+
```
61+
62+
# Field Types
63+
## Standard Fields
64+
These fields are generic and used in several products.
65+
66+
### BaseField
67+
Each prediction object contains a set of fields that inherit from the generic `BaseField` class.
68+
A typical `BaseField` object will have the following attributes:
69+
70+
* **value** (`Union[float, str]`): corresponds to the field value. Can be `None` if no value was extracted.
71+
* **confidence** (`float`): the confidence score of the field prediction.
72+
* **bounding_box** (`[Point, Point, Point, Point]`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
73+
* **polygon** (`List[Point]`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
74+
* **page_id** (`int`): the ID of the page, always `None` when at document-level.
75+
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
76+
77+
> **Note:** A `Point` simply refers to a List of two numbers (`[float, float]`).
78+
79+
80+
Aside from the previous attributes, all basic fields have access to a custom `__str__` method that can be used to print their value as a string.
81+
82+
### StringField
83+
The text field `StringField` only has one constraint: its **value** is an `Optional[str]`.
84+
85+
# Attributes
86+
The following fields are extracted for Business Card V1:
87+
88+
## Address
89+
**address** ([StringField](#stringfield)): The address of the person.
90+
91+
```py
92+
print(result.document.inference.prediction.address.value)
93+
```
94+
95+
## Company
96+
**company** ([StringField](#stringfield)): The company the person works for.
97+
98+
```py
99+
print(result.document.inference.prediction.company.value)
100+
```
101+
102+
## Email
103+
**email** ([StringField](#stringfield)): The email address of the person.
104+
105+
```py
106+
print(result.document.inference.prediction.email.value)
107+
```
108+
109+
## Fax Number
110+
**fax_number** ([StringField](#stringfield)): The Fax number of the person.
111+
112+
```py
113+
print(result.document.inference.prediction.fax_number.value)
114+
```
115+
116+
## Firstname
117+
**firstname** ([StringField](#stringfield)): The given name of the person.
118+
119+
```py
120+
print(result.document.inference.prediction.firstname.value)
121+
```
122+
123+
## Job Title
124+
**job_title** ([StringField](#stringfield)): The job title of the person.
125+
126+
```py
127+
print(result.document.inference.prediction.job_title.value)
128+
```
129+
130+
## Lastname
131+
**lastname** ([StringField](#stringfield)): The lastname of the person.
132+
133+
```py
134+
print(result.document.inference.prediction.lastname.value)
135+
```
136+
137+
## Mobile Number
138+
**mobile_number** ([StringField](#stringfield)): The mobile number of the person.
139+
140+
```py
141+
print(result.document.inference.prediction.mobile_number.value)
142+
```
143+
144+
## Phone Number
145+
**phone_number** ([StringField](#stringfield)): The phone number of the person.
146+
147+
```py
148+
print(result.document.inference.prediction.phone_number.value)
149+
```
150+
151+
## Social Media
152+
**social_media** (List[[StringField](#stringfield)]): The social media profiles of the person or company.
153+
154+
```py
155+
for social_media_elem in result.document.inference.prediction.social_media:
156+
print(social_media_elem.value)
157+
```
158+
159+
## Website
160+
**website** ([StringField](#stringfield)): The website of the person or company.
161+
162+
```py
163+
print(result.document.inference.prediction.website.value)
164+
```
165+
166+
# Questions?
167+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
title: Delivery note OCR Python
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: python-delivery-note-ocr
5+
parentDoc: 609808f773b0b90051d839de
6+
---
7+
The Python 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+
```py
14+
from mindee import Client, product, AsyncPredictResponse
15+
16+
# Init a new client
17+
mindee_client = Client(api_key="my-api-key")
18+
19+
# Load a file from disk
20+
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
21+
22+
# Load a file from disk and enqueue it.
23+
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
24+
product.DeliveryNoteV1,
25+
input_doc,
26+
)
27+
28+
# Print a brief summary of the parsed data
29+
print(result.document)
30+
31+
```
32+
33+
**Output (RST):**
34+
```rst
35+
########
36+
Document
37+
########
38+
:Mindee ID: d5ead821-edec-4d31-a69a-cf3998d9a506
39+
:Filename: default_sample.jpg
40+
41+
Inference
42+
#########
43+
:Product: mindee/delivery_notes v1.0
44+
:Rotation applied: Yes
45+
46+
Prediction
47+
==========
48+
:Delivery Date: 2019-10-02
49+
:Delivery Number: INT-001
50+
:Supplier Name: John Smith
51+
:Supplier Address: 4490 Oak Drive, Albany, NY 12210
52+
:Customer Name: Jessie M Horne
53+
:Customer Address: 4312 Wood Road, New York, NY 10031
54+
:Total Amount: 204.75
55+
```
56+
57+
# Field Types
58+
## Standard Fields
59+
These fields are generic and used in several products.
60+
61+
### BaseField
62+
Each prediction object contains a set of fields that inherit from the generic `BaseField` class.
63+
A typical `BaseField` object will have the following attributes:
64+
65+
* **value** (`Union[float, str]`): corresponds to the field value. Can be `None` if no value was extracted.
66+
* **confidence** (`float`): the confidence score of the field prediction.
67+
* **bounding_box** (`[Point, Point, Point, Point]`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
68+
* **polygon** (`List[Point]`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
69+
* **page_id** (`int`): the ID of the page, always `None` when at document-level.
70+
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
71+
72+
> **Note:** A `Point` simply refers to a List of two numbers (`[float, float]`).
73+
74+
75+
Aside from the previous attributes, all basic fields have access to a custom `__str__` method that can be used to print their value as a string.
76+
77+
78+
### AmountField
79+
The amount field `AmountField` only has one constraint: its **value** is an `Optional[float]`.
80+
81+
### DateField
82+
Aside from the basic `BaseField` attributes, the date field `DateField` also implements the following:
83+
84+
* **date_object** (`Date`): an accessible representation of the value as a python object. Can be `None`.
85+
86+
### StringField
87+
The text field `StringField` only has one constraint: its **value** is an `Optional[str]`.
88+
89+
# Attributes
90+
The following fields are extracted for Delivery note V1:
91+
92+
## Customer Address
93+
**customer_address** ([StringField](#stringfield)): The address of the customer receiving the goods.
94+
95+
```py
96+
print(result.document.inference.prediction.customer_address.value)
97+
```
98+
99+
## Customer Name
100+
**customer_name** ([StringField](#stringfield)): The name of the customer receiving the goods.
101+
102+
```py
103+
print(result.document.inference.prediction.customer_name.value)
104+
```
105+
106+
## Delivery Date
107+
**delivery_date** ([DateField](#datefield)): The date on which the delivery is scheduled to arrive.
108+
109+
```py
110+
print(result.document.inference.prediction.delivery_date.value)
111+
```
112+
113+
## Delivery Number
114+
**delivery_number** ([StringField](#stringfield)): A unique identifier for the delivery note.
115+
116+
```py
117+
print(result.document.inference.prediction.delivery_number.value)
118+
```
119+
120+
## Supplier Address
121+
**supplier_address** ([StringField](#stringfield)): The address of the supplier providing the goods.
122+
123+
```py
124+
print(result.document.inference.prediction.supplier_address.value)
125+
```
126+
127+
## Supplier Name
128+
**supplier_name** ([StringField](#stringfield)): The name of the supplier providing the goods.
129+
130+
```py
131+
print(result.document.inference.prediction.supplier_name.value)
132+
```
133+
134+
## Total Amount
135+
**total_amount** ([AmountField](#amountfield)): The total monetary value of the goods being delivered.
136+
137+
```py
138+
print(result.document.inference.prediction.total_amount.value)
139+
```
140+
141+
# Questions?
142+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)

docs/extras/guide/financial_document_v1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ print(result.document)
5858
########
5959
Document
6060
########
61-
:Mindee ID: 340ee4ae-b4da-41f0-b5ea-81ae29852b57
61+
:Mindee ID: b26161ce-35d0-4984-b1ff-886645e160e6
6262
:Filename: default_sample.jpg
6363
6464
Inference
6565
#########
66-
:Product: mindee/financial_document v1.10
66+
:Product: mindee/financial_document v1.11
6767
:Rotation applied: Yes
6868
6969
Prediction
7070
==========
71-
:Locale: en; en; USD;
71+
:Locale: en-US; en; US; USD;
7272
:Invoice Number: INT-001
7373
:Purchase Order Number: 2412/2019
7474
:Receipt Number:
@@ -120,7 +120,7 @@ Page Predictions
120120
121121
Page 0
122122
------
123-
:Locale: en; en; USD;
123+
:Locale: en-US; en; US; USD;
124124
:Invoice Number: INT-001
125125
:Purchase Order Number: 2412/2019
126126
:Receipt Number:

0 commit comments

Comments
 (0)