OCR / app /extract_country /country_extract.py
ShahzainHaider's picture
Upload folder using huggingface_hub
7bbae49
raw
history blame
701 Bytes
from extract_country.country_validator import extract_country_name
def country_extractor(ocr_list):
try:
country_found = False
country = None
result_string = ' '.join(string for string in ocr_list)
words = result_string.split()
for index,word in enumerate(words):
country_found, country_name = extract_country_name(word)
if country_found:
country_found = True
country = country_name
break
return country_found, country, ocr_list
except Exception as e:
print("[Exception in country_extractor ] ", str(e))
return country_found, country, ocr_list