Update punctuationManager.py
This commit is contained in:
parent
1f263b2cf0
commit
217ec6a2c0
@ -30,15 +30,16 @@ class punctuationManager():
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
def removeUnused(self, text):
|
def removeUnused(self, text):
|
||||||
resultText = text.translate(text.maketrans(string.punctuation, ' '*len(string.punctuation)))
|
return text.translate(text.maketrans(string.punctuation, ' '*len(string.punctuation)))
|
||||||
return resultText
|
|
||||||
def useCustomDict(self, text, customDict):
|
def useCustomDict(self, text, customDict):
|
||||||
resultText = text
|
resultText = text
|
||||||
|
if customDict:
|
||||||
for key,item in customDict.items():
|
for key,item in customDict.items():
|
||||||
resultText = resultText.replace(str(key),str(item))
|
resultText = resultText.replace(str(key),str(item))
|
||||||
return resultText
|
return resultText
|
||||||
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
||||||
resultText = str(text)
|
resultText = str(text)
|
||||||
|
if punctuationDict and punctuation != '':
|
||||||
for key,item in punctuationDict.items():
|
for key,item in punctuationDict.items():
|
||||||
if key in punctuation:
|
if key in punctuation:
|
||||||
resultText = resultText.replace(str(key),' ' +str(item) +' ')
|
resultText = resultText.replace(str(key),' ' +str(item) +' ')
|
||||||
|
Loading…
Reference in New Issue
Block a user