From fe44c40586ed90b67662d16b5703a6b3d852a1bf Mon Sep 17 00:00:00 2001 From: UndeadMaelys Date: Thu, 19 May 2022 19:19:00 +0200 Subject: [PATCH] improvement to apostrohpe separation --- strings.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/strings.lua b/strings.lua index 0487b18..9ce4339 100644 --- a/strings.lua +++ b/strings.lua @@ -44,15 +44,27 @@ end function minimum_apostrophes(str) local restr = "" for i = 1, #str do - if string.sub(str,i,i) == "'" then -- only makes sense to separate vowels from vowels + if string.sub(str,i,i) == "'" then -- only makes sense to separate vowels from vowel, or specified final separation- if string.find(string.sub(str,i-1,i-1),"[aeiou]") then if string.find(string.sub(str,i+1,i+1),"[aeiou]") then restr = restr .. string.sub(str,i,i) + else + if string.find(string.sub(str,i+2,i+2),"[aeiou]") then -- for patterns like V'CV where it isnt clear wether VC'V or VC'V only works for single consontants so... + restr = restr .. string.sub(str,i,i) + elseif string.find(string.sub(str,i+3,i+3),"[aeiou]") -- we check for those specifically + and (string.sub(str,i+1,i+2) == "sh" + or string.sub(str,i+1,i+2) == "ch" + or string.sub(str,i+1,i+2) == "ny") + then + restr = restr .. string.sub(str,i,i) + end end else -- only consontant meaningful of checking is n'y opposed to ny if string.find(string.sub(str,i-1,i-1),"[n]") and string.find(string.sub(str,i+1,i+1),"[y]") then restr = restr .. string.sub(str,i,i) + elseif string.find(string.sub(str,i+1,i+1),"[y]") then -- or consonant from vowels + restr = restr .. string.sub(str,i,i) end end else