Spaces:
Build error
Build error
gender_labels = ["M","MALE", "F", "FEMALE", "V/F","N/F","FEMENINO","MASCULINA"] | |
def gender_extract(ocr_list): | |
try: | |
for words in ocr_list: | |
for word in words.split(): | |
word = word.upper() | |
if word in gender_labels: | |
# ocr_list.pop(word) | |
return True, word, ocr_list | |
elif "FEMALE" in word: | |
# ocr_list.pop(word) | |
gender = 'F' | |
return True, gender, ocr_list | |
elif "MALE" in word: | |
# ocr_list.pop(word) | |
gender = 'M' | |
return True, gender, ocr_list | |
elif "FEMENINO" in word: | |
# ocr_list.pop(word) | |
gender = "F" | |
return True, gender, ocr_list | |
elif "MASCULINA" in word: | |
# ocr_list.pop(word) | |
gender = "M" | |
return True, gender, ocr_list | |
return False, None, ocr_list | |
except Exception as e: | |
print("[Exception in gender_extract] ", str(e)) | |
return None, None, ocr_list |