replace replace by sub
This commit is contained in:
parent
6b6de57c9e
commit
1155103389
@ -33,15 +33,14 @@ class punctuationManager():
|
|||||||
del currAllPunctNone[ord(char)]
|
del currAllPunctNone[ord(char)]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return text.translate(currAllPunctNone)
|
return text.translate(currAllPunctNone)
|
||||||
|
|
||||||
def useCustomDict(self, text, customDict, seperator=''):
|
def useCustomDict(self, text, customDict, seperator=''):
|
||||||
resultText = str(text)
|
resultText = str(text)
|
||||||
if customDict:
|
if customDict:
|
||||||
for key,item in customDict.items():
|
for key,item in customDict.items():
|
||||||
resultText = resultText.replace(str(key),seperator + str(item) + seperator)
|
#resultText = resultText.replace(str(key),seperator + str(item) + seperator)
|
||||||
|
resultText = re.sub(str(key), seperator + str(item) + seperator, resultText)
|
||||||
return resultText
|
return resultText
|
||||||
|
|
||||||
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
||||||
resultText = str(text)
|
resultText = str(text)
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ class punctuationManager():
|
|||||||
if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \
|
if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \
|
||||||
len(key) == 1 and \
|
len(key) == 1 and \
|
||||||
key in "',.;:?!":
|
key in "',.;:?!":
|
||||||
resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ')
|
resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ')
|
||||||
else:
|
else:
|
||||||
resultText = resultText.replace(str(key),' ' +str(item) + ' ')
|
resultText = resultText.replace(str(key),' ' +str(item) + ' ')
|
||||||
return resultText
|
return resultText
|
||||||
|
Loading…
Reference in New Issue
Block a user