From f52a1be1bcbce25595ce5d04bb090f6c697c6aa2 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 28 Jun 2018 23:59:56 +0200 Subject: [PATCH] respeckt puctuation in headline compression --- src/fenrirscreenreader/core/punctuationManager.py | 3 ++- src/fenrirscreenreader/core/textManager.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/punctuationManager.py b/src/fenrirscreenreader/core/punctuationManager.py index 0c8592a1..d665141f 100644 --- a/src/fenrirscreenreader/core/punctuationManager.py +++ b/src/fenrirscreenreader/core/punctuationManager.py @@ -57,7 +57,8 @@ class punctuationManager(): else: resultText = resultText.replace(str(key),' ' +str(item) + ' ') return resultText - + def isPuctuation(self, char): + return char in self.env['punctuation']['PUNCTDICT'] def proceedPunctuation(self, text, ignorePunctuation=False): resultText = text resultText = self.useCustomDict(resultText, self.env['punctuation']['CUSTOMDICT']) diff --git a/src/fenrirscreenreader/core/textManager.py b/src/fenrirscreenreader/core/textManager.py index b68aad34..05633f30 100644 --- a/src/fenrirscreenreader/core/textManager.py +++ b/src/fenrirscreenreader/core/textManager.py @@ -31,6 +31,9 @@ class textManager(): newText += text[lastPos:span[0]] numberOfChars = len(text[span[0]:span[1]]) 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]: newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: @@ -45,6 +48,9 @@ class textManager(): result += text[lastPos:span[0]] numberOfChars = len(newText[span[0]:span[1]]) 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]: result += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: