1
0
Fork 0
mirror of https://github.com/Findus23/cr-search.git synced 2024-09-19 15:23:44 +02:00
cr-search/typo.py

33 lines
965 B
Python
Raw Normal View History

2020-03-07 10:51:44 +01:00
"""
replace common typos of names to unify them in the database
"""
2020-03-07 10:45:39 +01:00
typos = {
"Matt": {"Mat", "Mattt", "\"Matt"},
"Sam": {"San", "Nott", "Sma", "Sasm", "Sm"},
"Travis": {"Tarvis", "Travs", "Travia", "Traivs"},
"Taliesin": {"Taiesin", "Talisin", "Talisen", "Taleisn", "Talisein"},
"Marisha": {"Beau", "Mariasha", "Maisha", "Marisa", "Marish", "Marihsa", "Marsha", "Marsisha", "Marishaa"},
"Laura": {"Lauda", "Lauren", "Larua", "Laur"},
"Liam": {"Caleb", "Laim"},
"Ashley": {"Ashly", "Ashely", "Ashey"},
"All": {"Everyone", "Everybody"},
"Mark": {"Marik"},
"Brian": {"Brain"}
}
replacements = {}
for correct, typoset in typos.items():
for typo in typoset:
replacements[typo] = correct
def fix_typo(text: str) -> str:
for search, replace in replacements.items():
if text == search.upper():
text = replace.upper()
return text
if __name__ == '__main__':
print(fix_typo("San"))