improvement to apostrohpe separation
This commit is contained in:
parent
21fd372eb2
commit
fe44c40586
14
strings.lua
14
strings.lua
@ -44,15 +44,27 @@ end
|
|||||||
function minimum_apostrophes(str)
|
function minimum_apostrophes(str)
|
||||||
local restr = ""
|
local restr = ""
|
||||||
for i = 1, #str do
|
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
|
||||||
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)
|
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
|
end
|
||||||
else -- only consontant meaningful of checking is n'y opposed to ny
|
else -- only consontant meaningful of checking is n'y opposed to ny
|
||||||
if string.find(string.sub(str,i-1,i-1),"[n]")
|
if string.find(string.sub(str,i-1,i-1),"[n]")
|
||||||
and string.find(string.sub(str,i+1,i+1),"[y]") then
|
and string.find(string.sub(str,i+1,i+1),"[y]") then
|
||||||
restr = restr .. string.sub(str,i,i)
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user