Improve sentence splitting logic

This commit is contained in:
Roman Jaroš 2025-03-05 15:00:11 +01:00
parent 8b53a5247c
commit 35e71cfa49
2 changed files with 6 additions and 7 deletions

View file

@ -8,7 +8,7 @@ end
local function SplitSentences(paragraph)
local sentences = {}
for sentence in string.gmatch(paragraph, "([^,%.%?!]+[,%.%?!]?)[%s]*") do
for sentence in string.gmatch(paragraph, "([^%.%?!]+[%.%?!]?)[%s]*") do
local trimmed = sentence:gsub("^%s+", ""):gsub("%s+$", "")
if #trimmed > 0 then
table.insert(sentences, trimmed)