Replace skipped punctuation with space. There's a setting in general, on by default, that will revert to old behavior if you replace it with false.

This commit is contained in:
Storm Dragon
2025-07-09 01:17:36 -04:00
parent 5e858cfde1
commit 01f4b64390
2 changed files with 28 additions and 0 deletions

View File

@ -49,11 +49,38 @@ class PunctuationManager:
def remove_unused(self, text, curr_level=""):
# dont translate dot and comma because they create a pause
curr_all_punct_none = self.allPunctNone.copy()
# Check if we should replace undefined punctuation with spaces
replace_with_space = self.env["runtime"]["SettingsManager"].get_setting_as_bool(
"general", "replaceUndefinedPunctuationWithSpace"
)
# If the setting is disabled, use the old behavior (remove completely)
if not replace_with_space:
# Create a map that removes undefined punctuation instead of replacing with spaces
curr_all_punct_none = dict.fromkeys(
map(ord, string.punctuation + "§ "), None
)
# Restore the pause-important characters
for char in [
ord("'"),
ord("."),
ord(","),
ord(";"),
ord(":"),
ord("?"),
ord("!"),
ord("-"),
]:
curr_all_punct_none[char] = chr(char)
# Remove characters that are defined in the current punctuation level
for char in curr_level:
try:
del curr_all_punct_none[ord(char)]
except Exception as e:
pass
return text.translate(curr_all_punct_none)
def use_custom_dict(self, text, customDict, seperator=""):

View File

@ -50,6 +50,7 @@ settings_data = {
"punctuationProfile": "default",
"punctuationLevel": "some",
"respectPunctuationPause": True,
"replaceUndefinedPunctuationWithSpace": True,
"newLinePause": True,
"numberOfClipboards": 10,
"emoticons": True,