Skip to content

Commit bf932b2

Browse files
committed
update all products to old-format rst
1 parent 506dc02 commit bf932b2

40 files changed

+313
-282
lines changed

mindee/documents/cropper/cropper_v1.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@
77
class CropperV1(Document):
88
"""Cropper v1 prediction results."""
99

10-
cropping: List[PositionField]
11-
"""List of all detected cropped elements in the image"""
10+
cropping: List[PositionField] = []
11+
"""List of documents found in the image."""
1212

1313
def __init__(
1414
self,
15-
api_prediction: TypeApiPrediction,
15+
api_prediction=None,
1616
input_source=None,
1717
page_n: Optional[int] = None,
1818
):
1919
"""
20-
Custom document object.
20+
Cropper v1 prediction results.
2121
22-
:param document_type: Document type
2322
:param api_prediction: Raw prediction from HTTP response
2423
:param input_source: Input object
2524
:param page_n: Page number for multi pages pdf input
@@ -35,27 +34,33 @@ def __init__(
3534
def _build_from_api_prediction(
3635
self, api_prediction: TypeApiPrediction, page_n: Optional[int] = None
3736
) -> None:
38-
"""Build the document from an API response JSON."""
39-
self.cropping = []
37+
"""
38+
Build the object from the prediction API JSON.
4039
41-
# cropping is only present on pages
40+
:param api_prediction: Raw prediction from HTTP response
41+
:param page_n: Page number
42+
"""
4243
if page_n is None:
4344
return
4445

45-
for crop in api_prediction["cropping"]:
46-
self.cropping.append(PositionField(prediction=crop, page_id=page_n))
46+
self.cropping = [
47+
PositionField(prediction, page_id=page_n)
48+
for prediction in api_prediction["cropping"]
49+
]
4750

48-
def _checklist(self) -> None:
49-
pass
50-
51-
def __str__(self):
52-
cropping = "\n ".join([str(crop) for crop in self.cropping])
51+
def __str__(self) -> str:
52+
cropping = f"\n { ' ' * 18 }".join(
53+
[str(item) for item in self.cropping],
54+
)
5355
return clean_out_string(
54-
"----- Cropper Data -----\n"
55-
f"Filename: {self.filename or ''}\n"
56-
f"Cropping: {cropping}\n"
57-
"------------------------"
56+
"Cropper V1 Prediction\n"
57+
"=====================\n"
58+
f":Filename: {self.filename or ''}\n"
59+
f":Document Cropper: {cropping}\n"
5860
)
5961

6062

61-
TypeCropperV1 = TypeVar("TypeCropperV1", bound=CropperV1)
63+
TypeCropperV1 = TypeVar(
64+
"TypeCropperV1",
65+
bound=CropperV1,
66+
)

mindee/documents/custom/custom_v1.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ def _build_from_api_prediction(
5757
self.fields[field_name] = ListField(prediction=field, page_n=page_n)
5858

5959
def __str__(self) -> str:
60-
custom_doc_str = f"----- {self.type} -----\nFilename: {self.filename or ''}\n"
60+
custom_doc_str = f"{self.type} V1 Prediction"
61+
custom_doc_str += "\n" + "=" * len(custom_doc_str)
62+
custom_doc_str += f"\n:Filename: {self.filename or ''}\n"
63+
6164
for class_name, class_info in self.classifications.items():
62-
custom_doc_str += f"{class_name}: {class_info}\n"
65+
custom_doc_str += f":{class_name}: {class_info}\n"
6366
for field_name, field_info in self.fields.items():
64-
custom_doc_str += f"{field_name}: {field_info}\n"
65-
custom_doc_str += "----------------------"
67+
custom_doc_str += f":{field_name}: {field_info}\n"
6668
return clean_out_string(custom_doc_str)
6769

6870

mindee/documents/eu/license_plate/license_plate_v1.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ def _build_from_api_prediction(
4646
]
4747

4848
def __str__(self) -> str:
49-
license_plates = f"\n { ' ' * 15 }".join(
50-
[str(item) for item in self.license_plates]
49+
license_plates = f"\n { ' ' * 16 }".join(
50+
[str(item) for item in self.license_plates],
5151
)
5252
return clean_out_string(
53-
"----- EU License Plate V1 -----\n"
54-
f"Filename: {self.filename or ''}\n"
55-
f"License Plates: { license_plates }\n"
56-
"----------------------"
53+
"EU License Plate V1 Prediction\n"
54+
"==============================\n"
55+
f":Filename: {self.filename or ''}\n"
56+
f":License Plates: {license_plates}\n"
5757
)
5858

5959

60-
TypeLicensePlateV1 = TypeVar("TypeLicensePlateV1", bound=LicensePlateV1)
60+
TypeLicensePlateV1 = TypeVar(
61+
"TypeLicensePlateV1",
62+
bound=LicensePlateV1,
63+
)

mindee/documents/financial_document/financial_document_v1.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,16 @@ def _line_items_to_str(self) -> str:
217217
return out_str
218218

219219
def __str__(self) -> str:
220-
customer_company_registrations = f"\n { ' ' * 31 }".join(
220+
customer_company_registrations = f"\n { ' ' * 32 }".join(
221221
[str(item) for item in self.customer_company_registrations],
222222
)
223-
reference_numbers = f"\n { ' ' * 18 }".join(
223+
reference_numbers = f"\n { ' ' * 19 }".join(
224224
[str(item) for item in self.reference_numbers],
225225
)
226-
supplier_company_registrations = f"\n { ' ' * 31 }".join(
226+
supplier_company_registrations = f"\n { ' ' * 32 }".join(
227227
[str(item) for item in self.supplier_company_registrations],
228228
)
229-
supplier_payment_details = f"\n { ' ' * 25 }".join(
229+
supplier_payment_details = f"\n { ' ' * 26 }".join(
230230
[str(item) for item in self.supplier_payment_details],
231231
)
232232
return clean_out_string(
@@ -259,4 +259,7 @@ def __str__(self) -> str:
259259
)
260260

261261

262-
TypeFinancialDocumentV1 = TypeVar("TypeFinancialDocumentV1", bound=FinancialDocumentV1)
262+
TypeFinancialDocumentV1 = TypeVar(
263+
"TypeFinancialDocumentV1",
264+
bound=FinancialDocumentV1,
265+
)

mindee/documents/fr/bank_account_details/bank_account_details_v1.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,16 @@ def _build_from_api_prediction(
5959

6060
def __str__(self) -> str:
6161
return clean_out_string(
62-
"----- FR Bank Account Details V1 -----\n"
63-
f"Filename: {self.filename or ''}\n"
64-
f"IBAN: { self.iban }\n"
65-
f"Account Holder's Name: { self.account_holder_name }\n"
66-
f"SWIFT Code: { self.swift }\n"
67-
"----------------------"
62+
"FR Bank Account Details V1 Prediction\n"
63+
"=====================================\n"
64+
f":Filename: {self.filename or ''}\n"
65+
f":IBAN: {self.iban}\n"
66+
f":Account Holder's Name: {self.account_holder_name}\n"
67+
f":SWIFT Code: {self.swift}\n"
6868
)
6969

7070

7171
TypeBankAccountDetailsV1 = TypeVar(
72-
"TypeBankAccountDetailsV1", bound=BankAccountDetailsV1
72+
"TypeBankAccountDetailsV1",
73+
bound=BankAccountDetailsV1,
7374
)

mindee/documents/fr/bank_account_details/bank_account_details_v2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ def __str__(self) -> str:
7878

7979

8080
TypeBankAccountDetailsV2 = TypeVar(
81-
"TypeBankAccountDetailsV2", bound=BankAccountDetailsV2
81+
"TypeBankAccountDetailsV2",
82+
bound=BankAccountDetailsV2,
8283
)

mindee/documents/fr/carte_vitale/carte_vitale_v1.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,21 @@ def _build_from_api_prediction(
6565
)
6666

6767
def __str__(self) -> str:
68-
given_names = f"\n { ' ' * 12 }".join(
68+
given_names = f"\n { ' ' * 15 }".join(
6969
[str(item) for item in self.given_names],
7070
)
7171
return clean_out_string(
72-
"----- FR Carte Vitale V1 -----\n"
73-
f"Filename: {self.filename or ''}\n"
74-
f"Given Name(s): { given_names }\n"
75-
f"Surname: { self.surname }\n"
76-
f"Social Security Number: { self.social_security }\n"
77-
f"Issuance Date: { self.issuance_date }\n"
78-
"----------------------"
72+
"FR Carte Vitale V1 Prediction\n"
73+
"=============================\n"
74+
f":Filename: {self.filename or ''}\n"
75+
f":Given Name(s): {given_names}\n"
76+
f":Surname: {self.surname}\n"
77+
f":Social Security Number: {self.social_security}\n"
78+
f":Issuance Date: {self.issuance_date}\n"
7979
)
8080

8181

82-
TypeCarteVitaleV1 = TypeVar("TypeCarteVitaleV1", bound=CarteVitaleV1)
82+
TypeCarteVitaleV1 = TypeVar(
83+
"TypeCarteVitaleV1",
84+
bound=CarteVitaleV1,
85+
)

mindee/documents/fr/id_card/id_card_v1.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,28 @@ def _build_from_api_prediction(
108108
)
109109

110110
def __str__(self) -> str:
111-
given_names = f"\n { ' ' * 12 }".join(
111+
given_names = f"\n { ' ' * 15 }".join(
112112
[str(item) for item in self.given_names],
113113
)
114114
return clean_out_string(
115-
"----- FR Carte Nationale d'Identité V1 -----\n"
116-
f"Filename: {self.filename or ''}\n"
117-
f"Document Side: { self.document_side }\n"
118-
f"Identity Number: { self.id_number }\n"
119-
f"Given Name(s): { given_names }\n"
120-
f"Surname: { self.surname }\n"
121-
f"Date of Birth: { self.birth_date }\n"
122-
f"Place of Birth: { self.birth_place }\n"
123-
f"Expiry Date: { self.expiry_date }\n"
124-
f"Issuing Authority: { self.authority }\n"
125-
f"Gender: { self.gender }\n"
126-
f"MRZ Line 1: { self.mrz1 }\n"
127-
f"MRZ Line 2: { self.mrz2 }\n"
128-
"----------------------"
115+
"FR Carte Nationale d'Identité V1 Prediction\n"
116+
"===========================================\n"
117+
f":Filename: {self.filename or ''}\n"
118+
f":Document Side: {self.document_side}\n"
119+
f":Identity Number: {self.id_number}\n"
120+
f":Given Name(s): {given_names}\n"
121+
f":Surname: {self.surname}\n"
122+
f":Date of Birth: {self.birth_date}\n"
123+
f":Place of Birth: {self.birth_place}\n"
124+
f":Expiry Date: {self.expiry_date}\n"
125+
f":Issuing Authority: {self.authority}\n"
126+
f":Gender: {self.gender}\n"
127+
f":MRZ Line 1: {self.mrz1}\n"
128+
f":MRZ Line 2: {self.mrz2}\n"
129129
)
130130

131131

132-
TypeIdCardV1 = TypeVar("TypeIdCardV1", bound=IdCardV1)
132+
TypeIdCardV1 = TypeVar(
133+
"TypeIdCardV1",
134+
bound=IdCardV1,
135+
)

mindee/documents/invoice_splitter/invoice_splitter_v1.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, prediction: Dict[str, Any]):
1919
pass
2020

2121
def __str__(self) -> str:
22-
return f"page indexes: {', '.join([str(page_index) for page_index in self.page_indexes])}"
22+
return f":Page indexes: {', '.join([str(page_index) for page_index in self.page_indexes])}"
2323

2424

2525
class InvoiceSplitterV1(Document):
@@ -61,17 +61,18 @@ def _build_from_api_prediction(
6161
]
6262

6363
def __str__(self) -> str:
64+
invoice_page_groups = ""
6465
if len(self.invoice_page_groups) > 0:
6566
invoice_page_groups = "\n "
6667
invoice_page_groups += f"\n{ ' ' * 2 }".join(
6768
[str(ivp) for ivp in self.invoice_page_groups]
6869
)
6970

7071
return clean_out_string(
71-
f"----- Invoice Splitter V1 -----\n"
72-
f"Filename: {self.filename or ''}\n"
73-
f"Invoice Page Groups: {invoice_page_groups}\n"
74-
f"----------------------"
72+
"Invoice Splitter V1 Prediction\n"
73+
"==============================\n"
74+
f":Filename: {self.filename or ''}\n"
75+
f":Invoice Page Groups: {invoice_page_groups}\n"
7576
)
7677

7778

mindee/documents/passport/passport_v1.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,24 @@ def _build_from_api_prediction(
120120
self.full_name = TextField({"value": None, "confidence": 0.0}, page_id=page_n)
121121

122122
def __str__(self) -> str:
123-
given_names = " ".join(
124-
[
125-
given_name.value if given_name.value is not None else ""
126-
for given_name in self.given_names
127-
]
123+
given_names = f"\n { ' ' * 15 }".join(
124+
[str(item) for item in self.given_names],
128125
)
129126
return clean_out_string(
130-
"----- Passport V1 -----\n"
131-
f"Filename: {self.filename or ''}\n"
132-
f"Full name: {self.full_name}\n"
133-
f"Given names: {given_names}\n"
134-
f"Surname: {self.surname}\n"
135-
f"Country: {self.country}\n"
136-
f"ID Number: {self.id_number}\n"
137-
f"Issuance date: {self.issuance_date}\n"
138-
f"Birth date: {self.birth_date}\n"
139-
f"Expiry date: {self.expiry_date}\n"
140-
f"MRZ 1: {self.mrz1}\n"
141-
f"MRZ 2: {self.mrz2}\n"
142-
f"MRZ: {self.mrz}\n"
143-
"----------------------"
127+
"Passport V1 Prediction\n"
128+
"======================\n"
129+
f":Filename: {self.filename or ''}\n"
130+
f":Country Code: {self.country}\n"
131+
f":ID Number: {self.id_number}\n"
132+
f":Given Name(s): {given_names}\n"
133+
f":Surname: {self.surname}\n"
134+
f":Date of Birth: {self.birth_date}\n"
135+
f":Place of Birth: {self.birth_place}\n"
136+
f":Gender: {self.gender}\n"
137+
f":Date of Issue: {self.issuance_date}\n"
138+
f":Expiry Date: {self.expiry_date}\n"
139+
f":MRZ Line 1: {self.mrz1}\n"
140+
f":MRZ Line 2: {self.mrz2}\n"
144141
)
145142

146143
def is_expired(self) -> bool:

0 commit comments

Comments
 (0)