We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5a0b42e + 9b28b31 commit d9c9cbaCopy full SHA for d9c9cba
1 file changed
source/speechDictHandler/__init__.py
@@ -47,6 +47,8 @@ def sub(self, text):
47
48
class SpeechDict(list):
49
50
+ fileName = None
51
+
52
def load(self, fileName):
53
self.fileName=fileName
54
comment=""
@@ -98,8 +100,16 @@ def save(self,fileName=None):
98
100
file.close()
99
101
102
def sub(self, text):
- for entry in self:
- text = entry.sub(text)
103
+ invalidEntries=[]
104
+ for index,entry in enumerate(self):
105
+ try:
106
+ text = entry.sub(text)
107
+ except re.error as exc:
108
+ dictName=self.fileName or "temporary dictionary"
109
+ log.error(f"Invalid dictionary entry {index+1} in {dictName}: \"{entry.pattern}\", {exc}")
110
+ invalidEntries.append(index)
111
+ for index in reversed(invalidEntries):
112
+ del self[index]
113
return text
114
115
def processText(text):
0 commit comments