Commit 302af819 authored by Vilem Ded's avatar Vilem Ded
Browse files

allow multiple surnames + check for titles in name

- get_names_from_strings now checks for title in name
- get_names_from_strings allow multiple surnames
parent 90a37cb2
......@@ -81,23 +81,28 @@ def process_possible_date(possible_date):
def get_names_from_string(full_name):
result = ['', '']
name = full_name.strip()
if name_cointains_title(name):
logging.error(f'Name contains titles: {name}')
if name.endswith(',') or name.endswith(','):
name = name[:-1]
if name is not None:
if " " in name:
name_list = name.split(" ")
len_name = len(name_list)
result[0] = name_list[0]
if len_name > 1:
result[1] = name_list[1]
if len_name == 3:
result[1] = result[1] + ' ' + name_list[2]
result[1] = " ".join(name_list[1:])
else:
result[0] = name
return result
def name_cointains_title(full_name):
full_name_dotless = full_name.replace(".", " ").lower()
titles = ['dr', 'prof', 'mr', 'mrs', 'ms', 'msc', 'mga', 'mph', 'sc', 'drph', 'rndr', 'phd', 'ph', 'msi']
name_list = full_name_dotless.split(" ")
res = [ele for ele in titles if(ele in name_list)]
return bool(res)
def get_lines_from_string(a_string):
result = []
stripped = a_string.strip()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment