Update punctuationManager.py

This commit is contained in:
chrys87 2016-09-22 16:50:26 +02:00 committed by GitHub
parent 1f263b2cf0
commit 217ec6a2c0

View File

@ -30,15 +30,16 @@ class punctuationManager():
def shutdown(self):
pass
def removeUnused(self, text):
resultText = text.translate(text.maketrans(string.punctuation, ' '*len(string.punctuation)))
return resultText
return text.translate(text.maketrans(string.punctuation, ' '*len(string.punctuation)))
def useCustomDict(self, text, customDict):
resultText = text
if customDict:
for key,item in customDict.items():
resultText = resultText.replace(str(key),str(item))
return resultText
def usePunctuationDict(self, text, punctuationDict, punctuation):
resultText = str(text)
if punctuationDict and punctuation != '':
for key,item in punctuationDict.items():
if key in punctuation:
resultText = resultText.replace(str(key),' ' +str(item) +' ')