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,18 +30,19 @@ 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
for key,item in customDict.items(): if customDict:
resultText = resultText.replace(str(key),str(item)) for key,item in customDict.items():
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)
for key,item in punctuationDict.items(): if punctuationDict and punctuation != '':
if key in punctuation: for key,item in punctuationDict.items():
resultText = resultText.replace(str(key),' ' +str(item) +' ') if key in punctuation:
resultText = resultText.replace(str(key),' ' +str(item) +' ')
return resultText return resultText
def proceedPunctuation(self, text, ignoreLevel=False): def proceedPunctuation(self, text, ignoreLevel=False):