Skip to content

Commit 50f05ff

Browse files
✨ add support for BillOfLadingV1, FR EnergyBillV1, NutritionFactsLabelV1, FR PayslipV1, UsMailV2 (#262)
1 parent 08c3c76 commit 50f05ff

File tree

89 files changed

+5507
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5507
-14
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.BillOfLadingV1,
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.fr.EnergyBillV1,
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.NutritionFactsLabelV1,
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.fr.PayslipV2,
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.us.UsMailV2,
12+
input_doc,
13+
)
14+
15+
# Print a brief summary of the parsed data
16+
print(result.document)
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
---
2+
title: Bill of Lading OCR Python
3+
category: 622b805aaec68102ea7fcbc2
4+
slug: python-bill-of-lading-ocr
5+
parentDoc: 609808f773b0b90051d839de
6+
---
7+
The Python OCR SDK supports the [Bill of Lading API](https://platform.mindee.com/mindee/bill_of_lading).
8+
9+
The [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/bill_of_lading/default_sample.jpg) can be used for testing purposes.
10+
![Bill of Lading sample](https://github.com/mindee/client-lib-test-data/blob/main/products/bill_of_lading/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.BillOfLadingV1,
25+
input_doc,
26+
)
27+
28+
# Print a brief summary of the parsed data
29+
print(result.document)
30+
31+
```
32+
# Field Types
33+
## Standard Fields
34+
These fields are generic and used in several products.
35+
36+
### BaseField
37+
Each prediction object contains a set of fields that inherit from the generic `BaseField` class.
38+
A typical `BaseField` object will have the following attributes:
39+
40+
* **value** (`Union[float, str]`): corresponds to the field value. Can be `None` if no value was extracted.
41+
* **confidence** (`float`): the confidence score of the field prediction.
42+
* **bounding_box** (`[Point, Point, Point, Point]`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document.
43+
* **polygon** (`List[Point]`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image.
44+
* **page_id** (`int`): the ID of the page, always `None` when at document-level.
45+
* **reconstructed** (`bool`): indicates whether an object was reconstructed (not extracted as the API gave it).
46+
47+
> **Note:** A `Point` simply refers to a List of two numbers (`[float, float]`).
48+
49+
50+
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.
51+
52+
### DateField
53+
Aside from the basic `BaseField` attributes, the date field `DateField` also implements the following:
54+
55+
* **date_object** (`Date`): an accessible representation of the value as a python object. Can be `None`.
56+
57+
### StringField
58+
The text field `StringField` only has one constraint: its **value** is an `Optional[str]`.
59+
60+
## Specific Fields
61+
Fields which are specific to this product; they are not used in any other product.
62+
63+
### Carrier Field
64+
The shipping company responsible for transporting the goods.
65+
66+
A `BillOfLadingV1Carrier` implements the following attributes:
67+
68+
* **name** (`str`): The name of the carrier.
69+
* **professional_number** (`str`): The professional number of the carrier.
70+
* **scac** (`str`): The Standard Carrier Alpha Code (SCAC) of the carrier.
71+
Fields which are specific to this product; they are not used in any other product.
72+
73+
### Consignee Field
74+
The party to whom the goods are being shipped.
75+
76+
A `BillOfLadingV1Consignee` implements the following attributes:
77+
78+
* **address** (`str`): The address of the consignee.
79+
* **email** (`str`): The email of the shipper.
80+
* **name** (`str`): The name of the consignee.
81+
* **phone** (`str`): The phone number of the consignee.
82+
Fields which are specific to this product; they are not used in any other product.
83+
84+
### Items Field
85+
The goods being shipped.
86+
87+
A `BillOfLadingV1CarrierItem` implements the following attributes:
88+
89+
* **description** (`str`): A description of the item.
90+
* **gross_weight** (`float`): The gross weight of the item.
91+
* **measurement** (`float`): The measurement of the item.
92+
* **measurement_unit** (`str`): The unit of measurement for the measurement.
93+
* **quantity** (`float`): The quantity of the item being shipped.
94+
* **weight_unit** (`str`): The unit of measurement for weights.
95+
Fields which are specific to this product; they are not used in any other product.
96+
97+
### Notify Party Field
98+
The party to be notified of the arrival of the goods.
99+
100+
A `BillOfLadingV1NotifyParty` implements the following attributes:
101+
102+
* **address** (`str`): The address of the notify party.
103+
* **email** (`str`): The email of the shipper.
104+
* **name** (`str`): The name of the notify party.
105+
* **phone** (`str`): The phone number of the notify party.
106+
Fields which are specific to this product; they are not used in any other product.
107+
108+
### Shipper Field
109+
The party responsible for shipping the goods.
110+
111+
A `BillOfLadingV1Shipper` implements the following attributes:
112+
113+
* **address** (`str`): The address of the shipper.
114+
* **email** (`str`): The email of the shipper.
115+
* **name** (`str`): The name of the shipper.
116+
* **phone** (`str`): The phone number of the shipper.
117+
118+
# Attributes
119+
The following fields are extracted for Bill of Lading V1:
120+
121+
## Bill of Lading Number
122+
**bill_of_lading_number** ([StringField](#stringfield)): A unique identifier assigned to a Bill of Lading document.
123+
124+
```py
125+
print(result.document.inference.prediction.bill_of_lading_number.value)
126+
```
127+
128+
## Carrier
129+
**carrier** ([BillOfLadingV1Carrier](#carrier-field)): The shipping company responsible for transporting the goods.
130+
131+
```py
132+
print(result.document.inference.prediction.carrier.value)
133+
```
134+
135+
## Items
136+
**carrier_items** (List[[BillOfLadingV1CarrierItem](#items-field)]): The goods being shipped.
137+
138+
```py
139+
for carrier_items_elem in result.document.inference.prediction.carrier_items:
140+
print(carrier_items_elem.value)
141+
```
142+
143+
## Consignee
144+
**consignee** ([BillOfLadingV1Consignee](#consignee-field)): The party to whom the goods are being shipped.
145+
146+
```py
147+
print(result.document.inference.prediction.consignee.value)
148+
```
149+
150+
## Date of issue
151+
**date_of_issue** ([DateField](#datefield)): The date when the bill of lading is issued.
152+
153+
```py
154+
print(result.document.inference.prediction.date_of_issue.value)
155+
```
156+
157+
## Departure Date
158+
**departure_date** ([DateField](#datefield)): The date when the vessel departs from the port of loading.
159+
160+
```py
161+
print(result.document.inference.prediction.departure_date.value)
162+
```
163+
164+
## Notify Party
165+
**notify_party** ([BillOfLadingV1NotifyParty](#notify-party-field)): The party to be notified of the arrival of the goods.
166+
167+
```py
168+
print(result.document.inference.prediction.notify_party.value)
169+
```
170+
171+
## Place of Delivery
172+
**place_of_delivery** ([StringField](#stringfield)): The place where the goods are to be delivered.
173+
174+
```py
175+
print(result.document.inference.prediction.place_of_delivery.value)
176+
```
177+
178+
## Port of Discharge
179+
**port_of_discharge** ([StringField](#stringfield)): The port where the goods are unloaded from the vessel.
180+
181+
```py
182+
print(result.document.inference.prediction.port_of_discharge.value)
183+
```
184+
185+
## Port of Loading
186+
**port_of_loading** ([StringField](#stringfield)): The port where the goods are loaded onto the vessel.
187+
188+
```py
189+
print(result.document.inference.prediction.port_of_loading.value)
190+
```
191+
192+
## Shipper
193+
**shipper** ([BillOfLadingV1Shipper](#shipper-field)): The party responsible for shipping the goods.
194+
195+
```py
196+
print(result.document.inference.prediction.shipper.value)
197+
```
198+
199+
# Questions?
200+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)

0 commit comments

Comments
 (0)