diff --git a/cleanbasestation.py b/cleanbasestation.py index 7ec6841..88f9040 100644 --- a/cleanbasestation.py +++ b/cleanbasestation.py @@ -73,6 +73,20 @@ SUBSTITUTIONS = { } +RE_SUBSTITUTIONS = [ + [re.compile(r'\bAS.?350.?B.?1'), 'AS 350 B1'], + [re.compile(r'\bAS.?350.?B.?2'), 'AS 350 B2'], + [re.compile(r'\bAS.?350.?B.?3'), 'AS 350 B3'], +] + +def do_re_substitutions(s): + new_s = s + for regex, replacement in RE_SUBSTITUTIONS: + new_s = regex.sub(replacement, new_s) + if new_s != s: + print([s, new_s]) + return new_s + def contains_upper_and_lower(s): return any(c.isupper() for c in s) and any(c.islower() for c in s) @@ -95,6 +109,7 @@ def fix_type(s): tokens = [title_case(t) for t in tokens] tokens = [SUBSTITUTIONS.get(t.lower(), t) for t in tokens] s = ' '.join(tokens) + s = do_re_substitutions(s) return s