From 7ed2436a1431ae0b45ddb3e93180f49d10f87f87 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 11 Nov 2017 00:42:55 +0100 Subject: [PATCH 1/2] fix punctuation --- src/fenrir/core/headLineManager.py | 13 +++++++------ src/fenrir/core/punctuationManager.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/fenrir/core/headLineManager.py b/src/fenrir/core/headLineManager.py index d04dc68d..0fa44703 100644 --- a/src/fenrir/core/headLineManager.py +++ b/src/fenrir/core/headLineManager.py @@ -30,10 +30,11 @@ class headLineManager(): newText += text[lastPos:span[0]] numberOfChars = len(text[span[0]:span[1]]) name = text[span[0]:span[1]][:2] - if name.strip(name[0]) == '': - newText += ' ' + str(numberOfChars) + ' ' + name[0] + ' ' + print(self.env['runtime']['punctuationManager'].proceedPunctuation(name, True)) + if name[0] == name[1]: + newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: - newText += ' ' + str(int(numberOfChars / 2)) + ' ' + name + ' ' + newText += ' ' + str(int(numberOfChars / 2)) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name, True) + ' ' lastPos = span[1] if lastPos != 0: newText += ' ' @@ -44,10 +45,10 @@ class headLineManager(): result += text[lastPos:span[0]] numberOfChars = len(newText[span[0]:span[1]]) name = newText[span[0]:span[1]][:2] - if name.strip(name[0]) == '': - result += ' ' + str(numberOfChars) + ' ' + name[0] + ' ' + if name[0] == name[1]: + result += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: - result += ' ' + str(int(numberOfChars / 2)) + ' ' + name + ' ' + result += ' ' + str(int(numberOfChars / 2)) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name, True) + ' ' lastPos = span[1] if lastPos != 0: result += ' ' diff --git a/src/fenrir/core/punctuationManager.py b/src/fenrir/core/punctuationManager.py index f10dca30..61f2f2ee 100644 --- a/src/fenrir/core/punctuationManager.py +++ b/src/fenrir/core/punctuationManager.py @@ -49,7 +49,7 @@ class punctuationManager(): if key in punctuation and key not in ' ': if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \ len(key) == 1 and \ - key in ",.;:?!-": + key in ",.;:?!": resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ') else: resultText = resultText.replace(str(key),' ' +str(item) + ' ') From 5da4ed37494c9869d159101989335ddff1cbc3fb Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 11 Nov 2017 00:47:11 +0100 Subject: [PATCH 2/2] finish --- src/fenrir/core/headLineManager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fenrir/core/headLineManager.py b/src/fenrir/core/headLineManager.py index 0fa44703..54ed1bb3 100644 --- a/src/fenrir/core/headLineManager.py +++ b/src/fenrir/core/headLineManager.py @@ -30,7 +30,6 @@ class headLineManager(): newText += text[lastPos:span[0]] numberOfChars = len(text[span[0]:span[1]]) name = text[span[0]:span[1]][:2] - print(self.env['runtime']['punctuationManager'].proceedPunctuation(name, True)) if name[0] == name[1]: newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' else: