respeckt puctuation in headline compression

This commit is contained in:
chrys 2018-06-28 23:59:56 +02:00
parent a91779732f
commit f52a1be1bc
2 changed files with 8 additions and 1 deletions

View File

@ -57,7 +57,8 @@ class punctuationManager():
else: else:
resultText = resultText.replace(str(key),' ' +str(item) + ' ') resultText = resultText.replace(str(key),' ' +str(item) + ' ')
return resultText return resultText
def isPuctuation(self, char):
return char in self.env['punctuation']['PUNCTDICT']
def proceedPunctuation(self, text, ignorePunctuation=False): def proceedPunctuation(self, text, ignorePunctuation=False):
resultText = text resultText = text
resultText = self.useCustomDict(resultText, self.env['punctuation']['CUSTOMDICT']) resultText = self.useCustomDict(resultText, self.env['punctuation']['CUSTOMDICT'])

View File

@ -31,6 +31,9 @@ class textManager():
newText += text[lastPos:span[0]] newText += text[lastPos:span[0]]
numberOfChars = len(text[span[0]:span[1]]) numberOfChars = len(text[span[0]:span[1]])
name = text[span[0]:span[1]][:2] name = text[span[0]:span[1]][:2]
if not self.env['runtime']['punctuationManager'].isPuctuation(name[0]):
lastPos = span[1]
continue
if name[0] == name[1]: if name[0] == name[1]:
newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' '
else: else:
@ -45,6 +48,9 @@ class textManager():
result += text[lastPos:span[0]] result += text[lastPos:span[0]]
numberOfChars = len(newText[span[0]:span[1]]) numberOfChars = len(newText[span[0]:span[1]])
name = newText[span[0]:span[1]][:2] name = newText[span[0]:span[1]][:2]
if not self.env['runtime']['punctuationManager'].isPuctuation(name[0]):
lastPos = span[1]
continue
if name[0] == name[1]: if name[0] == name[1]:
result += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' result += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' '
else: else: