88
99
1010class ProofOfAddressV1 (Document ):
11+ """Proof of Address v1 prediction results."""
12+
1113 locale : LocaleField
12- """locale information"""
13- date : DateField
14- """ISO date yyyy-mm-dd. Works both for European and US dates."""
15- dates : List [DateField ] = []
16- """All extracted ISO date yyyy-mm-dd"""
17- issuer_address : TextField
18- """Address of the document's issuer."""
19- issuer_company_registration : List [CompanyRegistrationField ] = []
20- """Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific."""
14+ """The locale detected on the document."""
2115 issuer_name : TextField
22- """Name of the person or company issuing the document."""
23- recipient_address : TextField
24- """Address of the recipient ."""
25- recipient_company_registration : List [ CompanyRegistrationField ] = []
26- """Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific ."""
16+ """The name of the person or company issuing the document."""
17+ issuer_company_registration : List [ CompanyRegistrationField ]
18+ """List of company registrations found for the issuer ."""
19+ issuer_address : TextField
20+ """The address of the document's issuer ."""
2721 recipient_name : TextField
28- """Name of the document's recipient."""
22+ """The name of the person or company receiving the document."""
23+ recipient_company_registration : List [CompanyRegistrationField ]
24+ """List of company registrations found for the recipient."""
25+ recipient_address : TextField
26+ """The address of the recipient."""
27+ dates : List [DateField ]
28+ """List of dates found on the document."""
29+ date : DateField
30+ """The date the document was issued."""
2931
3032 def __init__ (
3133 self ,
@@ -34,7 +36,7 @@ def __init__(
3436 page_n : Optional [int ] = None ,
3537 ):
3638 """
37- Proof of Address document .
39+ Proof of Address v1 prediction results .
3840
3941 :param api_prediction: Raw prediction from HTTP response
4042 :param input_source: Input object
@@ -55,56 +57,69 @@ def _build_from_api_prediction(
5557 Build the object from the prediction API JSON.
5658
5759 :param api_prediction: Raw prediction from HTTP response
58- :param page_n: Page number for multi pages pdf input
60+ :param page_n: Page number
5961 """
6062 self .locale = LocaleField (
61- api_prediction ["locale" ], value_key = "language" , page_n = page_n
63+ api_prediction ["locale" ],
64+ page_n = page_n ,
65+ )
66+ self .issuer_name = TextField (
67+ api_prediction ["issuer_name" ],
68+ page_n = page_n ,
6269 )
63- self .date = DateField (api_prediction ["date" ], page_n = page_n )
64- self .dates = [
65- DateField (tax_prediction , page_n = page_n )
66- for tax_prediction in api_prediction ["dates" ]
67- ]
68- self .issuer_name = TextField (api_prediction ["issuer_name" ], page_n = page_n )
69- self .issuer_address = TextField (api_prediction ["issuer_address" ], page_n = page_n )
7070 self .issuer_company_registration = [
71- CompanyRegistrationField (tax_prediction , page_n = page_n )
72- for tax_prediction in api_prediction ["issuer_company_registration" ]
71+ CompanyRegistrationField (prediction , page_n = page_n )
72+ for prediction in api_prediction ["issuer_company_registration" ]
7373 ]
74- self .recipient_name = TextField (api_prediction ["recipient_name" ], page_n = page_n )
75- self .recipient_address = TextField (
76- api_prediction ["recipient_address" ], page_n = page_n
74+ self .issuer_address = TextField (
75+ api_prediction ["issuer_address" ],
76+ page_n = page_n ,
77+ )
78+ self .recipient_name = TextField (
79+ api_prediction ["recipient_name" ],
80+ page_n = page_n ,
7781 )
7882 self .recipient_company_registration = [
79- CompanyRegistrationField (tax_prediction , page_n = page_n )
80- for tax_prediction in api_prediction ["recipient_company_registration" ]
83+ CompanyRegistrationField (prediction , page_n = page_n )
84+ for prediction in api_prediction ["recipient_company_registration" ]
8185 ]
86+ self .recipient_address = TextField (
87+ api_prediction ["recipient_address" ],
88+ page_n = page_n ,
89+ )
90+ self .dates = [
91+ DateField (prediction , page_n = page_n )
92+ for prediction in api_prediction ["dates" ]
93+ ]
94+ self .date = DateField (
95+ api_prediction ["date" ],
96+ page_n = page_n ,
97+ )
8298
8399 def __str__ (self ) -> str :
84- issuer_company_registrations = "; " .join (
85- [str (n .value ) for n in self .issuer_company_registration ]
100+ issuer_company_registration = f"\n { ' ' * 28 } " .join (
101+ [str (item ) for item in self .issuer_company_registration ],
102+ )
103+ recipient_company_registration = f"\n { ' ' * 31 } " .join (
104+ [str (item ) for item in self .recipient_company_registration ],
86105 )
87- recipient_company_registrations = "; " .join (
88- [str (n . value ) for n in self .recipient_company_registration ]
106+ dates = f" \n { ' ' * 6 } " .join (
107+ [str (item ) for item in self .dates ],
89108 )
90- dates = "\n " .join ([str (n .value ) for n in self .dates ])
91109 return clean_out_string (
92110 "----- Proof of Address V1 -----\n "
93111 f"Filename: { self .filename or '' } \n "
94- f"Locale: { self .locale } \n "
95- f"Issuer name : { self .issuer_name } \n "
96- f"Issuer Address : { self . issuer_address } \n "
97- f"Issuer Company Registrations : { issuer_company_registrations } \n "
98- f"Recipient name : { self .recipient_name } \n "
99- f"Recipient Address : { self . recipient_address } \n "
100- f"Recipient Company Registrations : { recipient_company_registrations } \n "
101- f"Issuance Date : { self . date } \n "
102- f"Dates : { dates } \n "
112+ f"Locale: { self .locale } \n "
113+ f"Issuer Name : { self .issuer_name } \n "
114+ f"Issuer Company Registrations : { issuer_company_registration } \n "
115+ f"Issuer Address : { self . issuer_address } \n "
116+ f"Recipient Name : { self .recipient_name } \n "
117+ f"Recipient Company Registrations : { recipient_company_registration } \n "
118+ f"Recipient Address : { self . recipient_address } \n "
119+ f"Dates : { dates } \n "
120+ f"Date of Issue : { self . date } \n "
103121 "----------------------"
104122 )
105123
106- def _checklist (self ) -> None :
107- pass
108-
109124
110125TypeProofOfAddressV1 = TypeVar ("TypeProofOfAddressV1" , bound = ProofOfAddressV1 )
0 commit comments