88
99
1010class PassportV1 (Document ):
11- """Cropper v1 prediction results."""
11+ """Passport v1 prediction results."""
1212
13+ birth_date : DateField
14+ """The date of birth of the passport holder."""
15+ birth_place : TextField
16+ """The place of birth of the passport holder."""
1317 country : TextField
14- """Country of issue"""
15- id_number : TextField
16- """Passport number"""
18+ """The country's 3 letter code (ISO 3166-1 alpha-3)."""
1719 expiry_date : DateField
18- """Date the passport expires"""
19- issuance_date : DateField
20- """Date the passport was issued"""
21- surname : TextField
22- """Holder's last name (surname)"""
23- given_names : List [TextField ]
24- """Holder's list of first (given) names"""
20+ """The expiry date of the passport."""
2521 full_name : TextField
2622 """
2723 Holder's full name.
2824 The combination of `given_names` and `surname` fields.
2925 """
30- birth_date : DateField
31- """Holder's date of birth"""
32- birth_place : TextField
33- """Holder's place of birth"""
3426 gender : TextField
35- """Holder's gender or sex"""
36- mrz1 : TextField
37- """First line of the Machine-Readable Zone"""
38- mrz2 : TextField
39- """Second line of the Machine-Readable Zone"""
27+ """The gender of the passport holder."""
28+ given_names : List [TextField ]
29+ """The given name(s) of the passport holder."""
30+ id_number : TextField
31+ """The passport's identification number."""
32+ issuance_date : DateField
33+ """The date the passport was issued."""
4034 mrz : TextField
4135 """Combination of both MRZ fields."""
36+ mrz1 : TextField
37+ """Machine Readable Zone, first line"""
38+ mrz2 : TextField
39+ """Machine Readable Zone, second line"""
40+ surname : TextField
41+ """The surname of the passport holder."""
4242
4343 def __init__ (
4444 self ,
@@ -47,7 +47,7 @@ def __init__(
4747 page_n : Optional [int ] = None ,
4848 ):
4949 """
50- Passport document .
50+ Passport v1 prediction results .
5151
5252 :param api_prediction: Raw prediction from HTTP response
5353 :param input_source: Input object
@@ -67,25 +67,55 @@ def _build_from_api_prediction(
6767 self , api_prediction : TypeApiPrediction , page_n : Optional [int ] = None
6868 ) -> None :
6969 """
70- Build the document from an API response JSON.
70+ Build the object from the prediction API JSON.
7171
7272 :param api_prediction: Raw prediction from HTTP response
7373 :param page_n: Page number for multi pages pdf input
7474 """
75- self .country = TextField (api_prediction ["country" ], page_id = page_n )
76- self .id_number = TextField (api_prediction ["id_number" ], page_id = page_n )
77- self .birth_date = DateField (api_prediction ["birth_date" ], page_id = page_n )
78- self .expiry_date = DateField (api_prediction ["expiry_date" ], page_id = page_n )
79- self .issuance_date = DateField (api_prediction ["issuance_date" ], page_id = page_n )
80- self .birth_place = TextField (api_prediction ["birth_place" ], page_id = page_n )
81- self .gender = TextField (api_prediction ["gender" ], page_id = page_n )
82- self .surname = TextField (api_prediction ["surname" ], page_id = page_n )
83- self .mrz1 = TextField (api_prediction ["mrz1" ], page_id = page_n )
84- self .mrz2 = TextField (api_prediction ["mrz2" ], page_id = page_n )
75+ self .birth_date = DateField (
76+ api_prediction ["birth_date" ],
77+ page_id = page_n ,
78+ )
79+ self .birth_place = TextField (
80+ api_prediction ["birth_place" ],
81+ page_id = page_n ,
82+ )
83+ self .country = TextField (
84+ api_prediction ["country" ],
85+ page_id = page_n ,
86+ )
87+ self .expiry_date = DateField (
88+ api_prediction ["expiry_date" ],
89+ page_id = page_n ,
90+ )
91+ self .gender = TextField (
92+ api_prediction ["gender" ],
93+ page_id = page_n ,
94+ )
8595 self .given_names = [
86- TextField (given_name , page_id = page_n )
87- for given_name in api_prediction ["given_names" ]
96+ TextField (prediction , page_id = page_n )
97+ for prediction in api_prediction ["given_names" ]
8898 ]
99+ self .id_number = TextField (
100+ api_prediction ["id_number" ],
101+ page_id = page_n ,
102+ )
103+ self .issuance_date = DateField (
104+ api_prediction ["issuance_date" ],
105+ page_id = page_n ,
106+ )
107+ self .mrz1 = TextField (
108+ api_prediction ["mrz1" ],
109+ page_id = page_n ,
110+ )
111+ self .mrz2 = TextField (
112+ api_prediction ["mrz2" ],
113+ page_id = page_n ,
114+ )
115+ self .surname = TextField (
116+ api_prediction ["surname" ],
117+ page_id = page_n ,
118+ )
89119 self .mrz = TextField ({"value" : None , "confidence" : 0.0 }, page_id = page_n )
90120 self .full_name = TextField ({"value" : None , "confidence" : 0.0 }, page_id = page_n )
91121
0 commit comments