MorseTranslator.py: fix sanitize_text
authorAntonio Ospite <ao2@ao2.it>
Mon, 14 Dec 2015 16:38:35 +0000 (17:38 +0100)
committerAntonio Ospite <ao2@ao2.it>
Mon, 14 Dec 2015 16:38:35 +0000 (17:38 +0100)
Use a regex more adherent to the characters actually translated, also
follow the order in which the characters appear in the signals table.

src/savemysugar/MorseTranslator.py

index 8184829..630aba7 100755 (executable)
@@ -138,7 +138,7 @@ class MorseTranslator(object):
 
     def sanitize_text(self, text):
         sanitized = text.lower()
 
     def sanitize_text(self, text):
         sanitized = text.lower()
-        sanitized = re.sub(r"[^a-z0-9.,?\'\"/() \-=\+@]", "", sanitized)
+        sanitized = re.sub(r"[^a-z0-9.,:?\'-/()\"=\+@ ]", "", sanitized)
         sanitized = re.sub(r"\s+", " ", sanitized)
         sanitized = re.sub(r"^\s+", "", sanitized)
         sanitized = re.sub(r"\s+$", "", sanitized)
         sanitized = re.sub(r"\s+", " ", sanitized)
         sanitized = re.sub(r"^\s+", "", sanitized)
         sanitized = re.sub(r"\s+$", "", sanitized)