From 259159e838db54a27845ee1ef52f7bcdc20d1ab5 Mon Sep 17 00:00:00 2001 From: John Wiseman Date: Fri, 27 Dec 2019 16:42:36 -0800 Subject: [PATCH] Foldes SUBSITITUTIONS into RE_SUBSTITUTIONS. --- cleanbasestation.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cleanbasestation.py b/cleanbasestation.py index ca1b73e..1cbda05 100644 --- a/cleanbasestation.py +++ b/cleanbasestation.py @@ -68,12 +68,9 @@ NOT_TITLE_CASE = [ TITLE_CASE_EXCEPTION_RE = re.compile('[0-9]') -SUBSTITUTIONS = { - 'mcdonnell': 'McDonnell' -} - - RE_SUBSTITUTIONS = [ + # "mcdonnell" -> "McDonnell" + [re.compile(r'\bmcdonnell\b', re.IGNORECASE), 'McDonnell'], # "AS.350-B-1" -> AS 350 B1" [re.compile(r'\bAS.?350.?B.?1'), 'AS 350 B1'], [re.compile(r'\bAS.?350.?B.?2'), 'AS 350 B2'], @@ -106,15 +103,15 @@ def title_case(s): return s.title() -# TODO: MCDONNELL -> McDonnell - def fix_type(s): + orig_s = s if s is not None: tokens = [p for p in s.split(' ') if p] 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) + # if s != orig_s: + # print([orig_s, s]) return s