Skip to content

Commit 4f4ce06

Browse files
authored
Anticrash (#19)
Merges anticrash updates
1 parent cd768c5 commit 4f4ce06

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

addon/synthDrivers/ibmeci.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,24 @@ def unicode(s): return s
3232
pause_re = re.compile(br'([a-zA-Z0-9]|\s)([%s])(\2*?)(\s|[\\/]|$)' %punctuation)
3333
time_re = re.compile(br"(\d):(\d+):(\d+)")
3434

35-
anticrash_res = {
36-
re.compile(br'\b(.*?)c(ae|\xe6)sur(e)?', re.I): br'\1seizur',
37-
re.compile(br"\b(|\d+|\W+)h'(r|v)[e]", re.I): br"\1h \2e",
38-
re.compile(br"\b(\w+[bdfhjlmnqrvz])(h[he]s)([abcdefghjklmnopqrstvwy]\w+)\b", re.I): br"\1 \2\3",
39-
re.compile(br"(\d):(\d\d[snrt][tdh])", re.I): br"\1 \2",
40-
re.compile(br"\b([bcdfghjklmnpqrstvwxz]+)'([bcdefghjklmnprstvwxz']+)'([drtv][aeiou]?)", re.I): br"\1 \2 \3",
41-
re.compile(br"\b(you+)'(re)+'([drv]e?)", re.I): br"\1 \2 \3",
42-
re.compile(br"(re|un|non|anti)cosp", re.I): br"\1kosp",
43-
re.compile(br"(EUR[A-Z]+)(\d+)", re.I): br"\1 \2",
44-
re.compile(br"\b(\d+|\W+|[bcdfghjklmnpqrstvwxz]+)?t+z[s]che", re.I): br"\1tz sche",
45-
re.compile(br"\b(juar[aeou]s)([aeiou]{6,})", re.I): br"\1 \2"
46-
}
47-
4835
english_fixes = {
4936
re.compile(r'(\w+)\.([a-zA-Z]+)'): r'\1 dot \2',
5037
re.compile(r'([a-zA-Z0-9_]+)@(\w+)'): r'\1 at \2',
5138
# Does not occur in normal use, however if a dictionary entry contains the Mc prefix, and NVDA splits it up, the synth will crash.
5239
# Also fixes ViaVoice, as the parser is more strict there and doesn't like spaces in Mc names.
53-
# this should be considered an english fix
54-
re.compile(r"\b(Mc)\s+([A-Z][a-z]+)"): r"\1\2"
40+
re.compile(r"\b(Mc)\s+([A-Z][a-z]+)"): r"\1\2",
41+
# Crash words, formerly part of anticrash_res.
42+
re.compile(r'\b(.*?)c(ae|\xe6)sur(e)?', re.I): r'\1seizur',
43+
re.compile(r"\b(|\d+|\W+)h'(r|v)[e]", re.I): r"\1h \2e",
44+
re.compile(r"\b(\w+[bdfhjlmnqrvz])(h[he]s)([abcdefghjklmnopqrstvwy]\w+)\b", re.I): r"\1 \2\3",
45+
re.compile(r"\b(\w+[bdfhjlmnqrvz])(h[he]s)(iron+[degins]?)", re.I): r"\1 \2\3",
46+
re.compile(r"(\d):(\d\d[snrt][tdh])", re.I): r"\1 \2",
47+
re.compile(r"\b([bcdfghjklmnpqrstvwxz]+)'([bcdefghjklmnprstvwxz']+)'([drtv][aeiou]?)", re.I): r"\1 \2 \3",
48+
re.compile(r"\b(you+)'(re)+'([drv]e?)", re.I): r"\1 \2 \3",
49+
re.compile(r"(re|un|non|anti)cosp", re.I): r"\1kosp",
50+
re.compile(r"(EUR[A-Z]+)(\d+)", re.I): r"\1 \2",
51+
re.compile(r"\b(\d+|\W+|[bcdfghjklmnpqrstvwxz]+)?t+z[s]che", re.I): r"\1tz sche",
52+
re.compile(r"\b(juar[aeou]s)([aeiou]{6,})", re.I): r"\1 \2"
5553
}
5654

5755
french_fixes = { re.compile(r'([a-zA-Z0-9_]+)@(\w+)'): r'\1 arobase \2' }
@@ -229,7 +227,7 @@ def speak(self,speechSequence):
229227

230228
def processText(self,text):
231229
text = text.rstrip()
232-
if _ibmeci.params[9] in (65536, 65537): text = resub(english_fixes, text)
230+
if _ibmeci.params[9] in (65536, 65537, 393216, 655360): text = resub(english_fixes, text) #Applies to Chinese and Korean as they can read English text and thus inherit the English bugs.
233231
if _ibmeci.params[9] in (131072, 131073): text = resub(spanish_fixes, text)
234232
if _ibmeci.params[9] in (196609, 196608):
235233
text = resub(french_fixes, text)
@@ -240,7 +238,6 @@ def processText(self,text):
240238
text = text.encode(self.currentEncoding, 'replace') # special unicode symbols may encode to backquote. For this reason, backquote processing is after this.
241239
if not self._backquoteVoiceTags:
242240
text=text.replace(b'`', b' ') # no embedded commands
243-
text = resub(anticrash_res, text)
244241
if self._shortpause:
245242
text = pause_re.sub(br'\1 `p1\2\3\4', text) # this enforces short, JAWS-like pauses.
246243
text = time_re.sub(br'\1:\2 \3', text) # apparently if this isn't done strings like 2:30:15 will only announce 2:30

0 commit comments

Comments
 (0)