Skip to content

Commit

Permalink
Incubates #5930
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsteh committed Sep 8, 2016
2 parents 94898a7 + eb19820 commit 584e8b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/speechDictHandler.py
Expand Up @@ -24,8 +24,8 @@

#Types of regexp for parsing numbers:
RE_SINGLE_DIGITS = re.compile(r"(\d)(?=\d+(\D|\b))", re.UNICODE)
RE_DOUBLE_DIGITS = re.compile(r"(\d{1,2})(?=(\d{2})+(\D|\b))", re.UNICODE)
RE_TRIPLE_DIGITS = re.compile(r"(\d{1,3})(?=(\d{3})+(\D|\b))", re.UNICODE)
RE_DOUBLE_DIGITS = re.compile(r"(\d{0,2})(?=(\d{2})+(\D|\b))", re.UNICODE)
RE_TRIPLE_DIGITS = re.compile(r"(\d{0,3})(?=(\d{3})+(\D|\b))", re.UNICODE)

class SpeechDictEntry:

Expand Down Expand Up @@ -109,12 +109,13 @@ def sub(self, text):

def processNumbers(numberSetting, text):
#0: processes default behavior. 1-3: splits on single-triple digits.
#Use two spaces instead of one, because some locales use space as thousands separator.
if numberSetting == 1:
text = RE_SINGLE_DIGITS.sub(r"\1 ", text)
text = RE_SINGLE_DIGITS.sub(r" \1 ", text)
elif numberSetting == 2:
text = RE_DOUBLE_DIGITS.sub(r"\1 ", text)
text = RE_DOUBLE_DIGITS.sub(r" \1 ", text)
elif numberSetting == 3:
text = RE_TRIPLE_DIGITS.sub(r"\1 ", text)
text = RE_TRIPLE_DIGITS.sub(r" \1 ", text)
return text


Expand Down

0 comments on commit 584e8b4

Please sign in to comment.