From 825b29144ea6a84ffd77a073a96aaec51c23d472 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Thu, 26 Dec 2019 22:33:25 -0800 Subject: [PATCH] Fixes for AS 350 helicopters. --- cleanbasestation.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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