Revert "replace replace by sub"

This reverts commit 7f91223f94.
This commit is contained in:
Chrys
2019-08-29 17:52:57 +02:00
parent 7f91223f94
commit 6b6de57c9e
2 changed files with 16 additions and 31 deletions

View File

@ -33,14 +33,15 @@ class punctuationManager():
del currAllPunctNone[ord(char)]
except:
pass
return text.translate(currAllPunctNone)
return text.translate(currAllPunctNone)
def useCustomDict(self, text, customDict, seperator=''):
resultText = str(text)
if customDict:
for key,item in customDict.items():
#resultText = resultText.replace(str(key),seperator + str(item) + seperator)
resultText = re.sub(str(key), str(item), resultText)
resultText = resultText.replace(str(key),seperator + str(item) + seperator)
return resultText
def usePunctuationDict(self, text, punctuationDict, punctuation):
resultText = str(text)
@ -52,7 +53,7 @@ class punctuationManager():
if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \
len(key) == 1 and \
key in "',.;:?!":
resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ')
resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ')
else:
resultText = resultText.replace(str(key),' ' +str(item) + ' ')
return resultText