16
16
KEY_FIRST_NAME_ANNOTATOR = "VORNAME"
17
17
KEY_PRISONER_NUMBER_ANNOTATOR = "HAEFTLINGSNUMMER"
18
18
KEY_DATE_OF_BIRTH_ANNOTATOR = "GEBURTSDATUM"
19
+ KEY_BIRTH_PLACE_ANNOTATOR = "GEBURTSORT"
19
20
20
21
21
22
def image_has_pre_annotated_data (image_path : str ) -> bool :
@@ -56,13 +57,15 @@ def apply_pre_annotated_csv(image_path: str, table: Table, offset: int = 0) -> C
56
57
first_name_column = find_column (table , KEY_FIRST_NAME_ANNOTATOR )
57
58
prisoner_number_column = find_column (table , KEY_PRISONER_NUMBER_ANNOTATOR )
58
59
birthdate_column = find_column (table , KEY_DATE_OF_BIRTH_ANNOTATOR )
60
+ birthplace_colum = find_column (table , KEY_BIRTH_PLACE_ANNOTATOR )
59
61
60
62
for line in lines :
61
63
key = int (line [KEY_ORDER ])
62
64
if key not in required_lines :
63
65
continue
64
66
row = cells [key - offset ]
65
- if last_name_column is not None and last_name_column == first_name_column :
67
+ if last_name_column is not None and last_name_column == first_name_column \
68
+ and KEY_LAST_NAME in line and KEY_FIRST_NAME in line :
66
69
last_name_index = table .columnTypes [last_name_column ].index (
67
70
KEY_LAST_NAME_ANNOTATOR )
68
71
first_name_index = table .columnTypes [last_name_column ].index (
@@ -73,15 +76,18 @@ def apply_pre_annotated_csv(image_path: str, table: Table, offset: int = 0) -> C
73
76
text = f"{ line [KEY_FIRST_NAME ].title ()} { line [KEY_LAST_NAME ].title ()} "
74
77
row [last_name_column ].ocr_text = text
75
78
else :
76
- if last_name_column is not None :
79
+ if last_name_column is not None and KEY_LAST_NAME in line :
77
80
row [last_name_column ].ocr_text = line [KEY_LAST_NAME ].title ()
78
- if first_name_column is not None :
81
+ if first_name_column is not None and KEY_FIRST_NAME in line :
79
82
row [first_name_column ].ocr_text = line [KEY_FIRST_NAME ].title ()
80
83
81
- if prisoner_number_column is not None :
84
+ if prisoner_number_column is not None and KEY_PRISONER_NUMBER in line :
82
85
row [prisoner_number_column ].ocr_text = line [KEY_PRISONER_NUMBER ]
83
- if birthdate_column is not None :
86
+ if birthdate_column is not None and KEY_DATE_OF_BIRTH in line :
84
87
row [birthdate_column ].ocr_text = \
85
88
transform_birthdate (line [KEY_DATE_OF_BIRTH ])
86
89
90
+ if birthplace_colum is not None and KEY_BIRTH_PLACE in line :
91
+ row [birthplace_colum ].ocr_text = line [KEY_BIRTH_PLACE ].title ()
92
+
87
93
return cells
0 commit comments