Skip to content

Commit c047050

Browse files
committed
📝 update the guide
1 parent e15ef3f commit c047050

File tree

3 files changed

+145
-102
lines changed

3 files changed

+145
-102
lines changed

docs/guide/python-invoice-ocr.md

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,46 @@ mindee_client = Client(api_key="my-api-key")
1414
# Load a file from disk
1515
input_doc = mindee_client.doc_from_path("/path/to/the/file.ext")
1616

17-
# Parse the document as an Invoice by passing the appropriate type
18-
api_response = input_doc.parse(documents.TypeInvoiceV4)
17+
# Parse the Invoice by passing the appropriate type
18+
result = input_doc.parse(documents.TypeInvoiceV4)
1919

20-
print(api_response.document)
20+
# Print a brief summary of the parsed data
21+
print(result.document)
2122
```
2223

2324
Output:
2425
```
25-
----- Invoice V4 -----
26-
Filename: a74eaa5-c8e283b-sample_invoice.jpeg
27-
Locale: en; en; CAD;
28-
Invoice number: 14
29-
Reference numbers: AD29094
30-
Invoice date: 2018-09-25
31-
Invoice due date: 2018-09-25
32-
Supplier name: TURNPIKE DESIGNS CO.
33-
Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
34-
Supplier company registrations:
35-
Supplier payment details:
36-
Customer name: JIRO DOI
37-
Customer company registrations:
38-
Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
39-
Line Items:
26+
Invoice V4 Prediction
27+
=====================
28+
:Filename:
29+
:Locale: fr; fr; EUR;
30+
:Invoice number: 0042004801351
31+
:Reference numbers: AD29094
32+
:Invoice date: 2020-02-17
33+
:Invoice due date: 2020-02-17
34+
:Supplier name: TURNPIKE DESIGNS CO.
35+
:Supplier address: 156 University Ave, Toronto ON, Canada M5H 2H7
36+
:Supplier company registrations: 501124705; FR33501124705
37+
:Supplier payment details: FR7640254025476501124705368;
38+
:Customer name: JIRO DOI
39+
:Customer company registrations: FR00000000000; 111222333
40+
:Customer address: 1954 Bloon Street West Toronto, ON, M6P 3K9 Canada
41+
:Line Items:
4042
Code | QTY | Price | Amount | Tax (Rate) | Description
41-
| 1.00 | 65.00 | 65.00 | | Platinum web hosting package Dow...
42-
| 3.00 | 2100.00 | 2100.00 | | 2 page website design Includes b...
43-
| 1.00 | 250.00 | 250.00 | | Mobile designs Includes responsi...
44-
Taxes: 193.20 8.00%
45-
Total taxes: 193.20
46-
Total amount excluding taxes: 2415.00
47-
Total amount including taxes: 2608.20
48-
----------------------
43+
| | | 4.31 | (2.10%) | PQ20 ETIQ ULTRA RESIS METAXXDC
44+
| 1.00 | 65.00 | 75.00 | 10.00 | Platinum web hosting package Dow...
45+
XXX81125600010 | 1.00 | 250.01 | 275.51 | 25.50 (10.20%) | a long string describing the ite...
46+
ABC456 | 200.30 | 8.101 | 1622.63 | 121.70 (7.50%) | Liquid perfection
47+
| | | | | CARTOUCHE L NR BROTHER TN247BK
48+
:Taxes:
49+
+---------------+--------+----------+---------------+
50+
| Base | Code | Rate (%) | Amount |
51+
+===============+========+==========+===============+
52+
| | | 20.00 | 97.98 |
53+
+---------------+--------+----------+---------------+
54+
:Total tax: 97.98
55+
:Total net: 489.97
56+
:Total amount: 587.95
4957
```
5058

5159
## Invoice Data Structure
@@ -64,23 +72,23 @@ Basically, we iterate over each page, and for each field, we keep the one that h
6472
For example, if you send a three-page invoice, the document level will provide you with one tax, one total, and so on.
6573

6674
```python
67-
print(api_response.document)
75+
print(result.document)
6876
```
6977

7078
### Page Level Prediction
7179
For page level prediction, in a multi-page pdf we construct the document class by using a unique page of the pdf.
7280

7381
```python
7482
# [InvoiceV4, InvoiceV4 ...]
75-
invoice_data.pages
83+
result.pages
7684
```
7785

7886
### Raw HTTP Response
7987
This contains the full Mindee API HTTP response object in JSON format
8088

8189
```python
8290
# full HTTP request object
83-
invoice_data.http_response
91+
result.http_response
8492
```
8593

8694
## Extracted Fields
@@ -112,21 +120,21 @@ Depending on the field type, there might be additional attributes that will be e
112120

113121
```python
114122
# To get the customer name (string)
115-
customer_name = invoice_data.document.customer_name.value
123+
customer_name = result.document.customer_name.value
116124
```
117125

118126
- **customer_address**: Customer's address
119127

120128
```python
121129
# To get the customer address (string)
122-
customer_address = invoice_data.document.customer_address.value
130+
customer_address = result.document.customer_address.value
123131
```
124132

125133
- **customer_company_registrations**: Customer Company Registration
126134

127135
```python
128136
# To get the customer company registation (string)
129-
customer_company_registrations = invoice_data.document.customer_company_registrations
137+
customer_company_registrations = result.document.customer_company_registrations
130138

131139
for customer_company_registration in customer_company_registrations:
132140
# To get the type of number
@@ -143,14 +151,14 @@ for customer_company_registration in customer_company_registrations:
143151

144152
```python
145153
# To get the invoice date of issuance (string)
146-
invoice_date = invoice_data.document.invoice_date.value
154+
invoice_date = result.document.invoice_date.value
147155
```
148156

149157
- **due_date**: Payment due date of the invoice.
150158

151159
```python
152160
# To get the invoice due date (string)
153-
due_date = invoice_data.document.due_date.value
161+
due_date = result.document.due_date.value
154162
```
155163

156164
### Locale and Currency
@@ -159,14 +167,14 @@ due_date = invoice_data.document.due_date.value
159167

160168
```python
161169
# To get the total language code
162-
language = invoice_data.document.locale.value
170+
language = result.document.locale.value
163171
```
164172

165173
- **currency** (String): ISO currency code.
166174

167175
``` python
168176
# To get the invoice currency code
169-
currency = invoice_data.document.locale.currency
177+
currency = result.document.locale.currency
170178
```
171179

172180
### Payment Information
@@ -179,7 +187,7 @@ currency = invoice_data.document.locale.currency
179187

180188
```python
181189
# To get the list of payment details
182-
payment_details = invoice_data.document.payment_details
190+
payment_details = result.document.payment_details
183191

184192
# Loop on each object
185193
for payment_detail in payment_details:
@@ -206,7 +214,7 @@ for payment_detail in payment_details:
206214

207215
```python
208216
# To get the list of payment details
209-
reference_numbers = invoice_data.document.reference_numbers
217+
reference_numbers = result.document.reference_numbers
210218

211219
# Loop on each object
212220
for reference_number in reference_numbers:
@@ -222,7 +230,7 @@ for reference_number in reference_numbers:
222230

223231
```python
224232
# To get the list of company numbers
225-
supplier_company_registrations = invoice_data.document.supplier_company_registrations
233+
supplier_company_registrations = result.document.supplier_company_registrations
226234

227235
# Loop on each object
228236
for company_registration in supplier_company_registrations:
@@ -237,14 +245,14 @@ for company_registration in supplier_company_registrations:
237245

238246
```python
239247
# To get the supplier name
240-
supplier_name = invoice_data.document.supplier_name.value
248+
supplier_name = result.document.supplier_name.value
241249
```
242250

243251
- **supplier_address**: Supplier address as written in the invoice.
244252

245253
```python
246254
# To get the supplier address
247-
supplier_address = invoice_data.document.supplier_address.value
255+
supplier_address = result.document.supplier_address.value
248256
```
249257

250258
### Taxes
@@ -255,7 +263,7 @@ supplier_address = invoice_data.document.supplier_address.value
255263

256264
```python
257265
# To get the list of taxes
258-
taxes = invoice_data.document.taxes
266+
taxes = result.document.taxes
259267

260268
# Loop on each Tax field
261269
for tax in taxes:
@@ -275,21 +283,21 @@ for tax in taxes:
275283

276284
```python
277285
# To get the total amount including taxes value (float), ex: 14.24
278-
total_amount = invoice_data.document.total_amount.value
286+
total_amount = result.document.total_amount.value
279287
```
280288

281289
- **total_net**: Total amount excluding taxes.
282290

283291
```python
284292
# To get the total amount excluding taxes value (float), ex: 10.21
285-
total_net = invoice_data.document.total_net.value
293+
total_net = result.document.total_net.value
286294
```
287295

288296
- **total_tax**: Total tax value from tax lines.
289297

290298
```python
291299
# To get the total tax amount value (float), ex: 8.42
292-
total_tax = invoice_data.document.total_tax.value
300+
total_tax = result.document.total_tax.value
293301
```
294302

295303
### Line Items
@@ -307,7 +315,7 @@ total_tax = invoice_data.document.total_tax.value
307315

308316
```python
309317
# Loop on line items
310-
for line_item in invoice_data.document.line_items:
318+
for line_item in result.document.line_items:
311319
# Show just the description
312320
print(line_item.description)
313321

docs/guide/python-passport-ocr.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ mindee_client = Client(api_key="my-api-key")
99
# Load a file from disk
1010
input_doc = mindee_client.doc_from_path("/path/to/the/file.ext")
1111

12-
# Parse the document as an Invoice by passing the appropriate type
13-
api_response = input_doc.parse(documents.TypePassportV1)
12+
# Parse the Passport by passing the appropriate type
13+
result = input_doc.parse(documents.TypePassportV1)
1414

15-
print(api_response.document)
15+
# Print a brief summary of the parsed data
16+
print(result.document)
1617
```
1718

1819
Using this sample fake passport below, we are going to illustrate how to extract the data that we want using the SDK.
@@ -62,14 +63,14 @@ We create the document class by iterating over each page one by one. Each page i
6263
For example, if you send a three-page passport, the page-level prediction will provide you with three names, three-countries codes, and so on.
6364

6465
```python
65-
print(passport_data.pages)
66+
print(result.pages)
6667
```
6768

6869
### Raw HTTP Response
6970
Contains the full Mindee API HTTP response object in JSON format
7071

7172
```python
72-
receipt_data.http_response # full HTTP request object
73+
result.http_response # full HTTP request object
7374
```
7475

7576

@@ -103,15 +104,15 @@ Using the above example, the following are the basic fields that can be extracte
103104

104105
```python
105106
# To get the passport's owner date of birth
106-
birth_date = passport_data.document.birth_date.value
107+
birth_date = result.document.birth_date.value
107108
print("DOB: ", birth_date)
108109
```
109110

110111
- **birth_place** (string): Passport owner birthplace.
111112

112113
```python
113114
# To get the passport's owner
114-
birth_place = passport_data.document.birth_place.value
115+
birth_place = result.document.birth_place.value
115116
print("birthplace: ", birth_place)
116117
```
117118

@@ -120,7 +121,7 @@ print("birthplace: ", birth_place)
120121

121122
```python
122123
# To get the passport country code
123-
country_code = passport_data.document.country.value
124+
country_code = result.document.country.value
124125
print("passport country code: ", country_code)
125126
```
126127

@@ -129,7 +130,7 @@ print("passport country code: ", country_code)
129130

130131
```python
131132
# To get the passport expiry date
132-
expiry_date = passport_data.document.expiry_date.value
133+
expiry_date = result.document.expiry_date.value
133134
print("expires: ", expiry_date)
134135
```
135136

@@ -138,7 +139,7 @@ print("expires: ", expiry_date)
138139

139140
```python
140141
# To get the passport's owner gender (string among {"M", "F"}
141-
gender = passport_data.document.gender.value
142+
gender = result.document.gender.value
142143
print("gender: ", gender)
143144
```
144145

@@ -147,7 +148,7 @@ print("gender: ", gender)
147148

148149
```python
149150
# To get the list of names
150-
given_names = passport_data.document.given_names
151+
given_names = result.document.given_names
151152
print("Given names: ")
152153
# Loop on each given name
153154
for given_name in given_names:
@@ -161,7 +162,7 @@ print(name)
161162

162163
```python
163164
# To get the passport id number (string)
164-
id_number = passport_data.document.id_number.value
165+
id_number = result.document.id_number.value
165166
print("passport number: ", id_number)
166167
```
167168

@@ -170,7 +171,7 @@ print("passport number: ", id_number)
170171

171172
```python
172173
# To get the passport date of issuance
173-
issuance_date = passport_data.document.issuance_date.value
174+
issuance_date = result.document.issuance_date.value
174175
print("issued: ", issuance_date)
175176
```
176177

@@ -179,23 +180,23 @@ print("issued: ", issuance_date)
179180

180181
```python
181182
# To get the passport first line of machine readable zone (string)
182-
mrz1 = passport_data.document.mrz1.value
183+
mrz1 = result.document.mrz1.value
183184
print("mrz1: ", mrz1)
184185
```
185186

186187
- **mrz2** (string): Passport second line of machine-readable zone.
187188

188189
```python
189190
# To get the passport full machine-readable zone (string)
190-
mrz2 = passport_data.document.mrz2.value
191+
mrz2 = result.document.mrz2.value
191192
print("mrz2: ", mrz2)
192193
```
193194

194195
- **mrz** (string): Reconstructed passport full machine readable zone from mrz1 and mrz2.
195196

196197
```python
197198
# To get the passport full machine readable zone (string)
198-
mrz = passport_data.document.mrz
199+
mrz = result.document.mrz
199200
print("mrz: ", mrz)
200201
```
201202

@@ -204,7 +205,7 @@ print("mrz: ", mrz)
204205

205206
```python
206207
# To get the passport's owner surname
207-
surname = passport_data.document.surname.value
208+
surname = result.document.surname.value
208209
print("surname: ", surname)
209210
```
210211

0 commit comments

Comments
 (0)