45,645
edits
No edit summary |
No edit summary |
||
Line 66: | Line 66: | ||
} | } | ||
local function syllabify( | local function syllabify(word) | ||
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·") | |||
word = gsub(word, "··", "·"); word = gsub(word, "·$", ""); word = gsub(word, "^·", "") | |||
word = gsub(word, "·(" .. consonants .. ")(" .. consonants .. ")(" .. vowels .. "*)", "%1·%2%3") | |||
word = gsub(word, "·(" .. consonants .. ")$", "%1") | |||
word = gsub(word, "·(" .. consonants .. ")·", "%1·") | |||
word = gsub(word, "(" .. consonants .. ")·(" .. consonants .. ")([pbmvstdnrɾlkɡŋhxçʤʧçx])", "%1%2·%3") | |||
local syllables = split(word, "·"); | |||
if #syllables ~= 1 then | |||
for i, syll in ipairs(syllables) do | |||
if match(syll, "´") or match(syll, "ː") then | |||
table.insert(syllables, i, "ˈ") | |||
return table.concat(syllables, "·") | |||
elseif match(word, "ŋ$") or match(syllables[#syllables], "[aeiouɛɪɔʊ][aeiouɛɪɔʊj]") then | |||
table.insert(syllables, #syllables, "ˈ") | |||
return table.concat(syllables, "·") | |||
--[[else | |||
table.insert(syllables, #syllables-1, "ˈ") | |||
return ret]] | |||
end | |||
end | |||
local | local ret = table.concat(syllables, "·"); | ||
if not match(ret, "ˈ") then | |||
syllables = split(ret, "·") | |||
syllables[#syllables - 1] = "ˈ" .. syllables[#syllables - 1] | |||
ret = table.concat(syllables, "·") | |||
end | end | ||
end | end | ||
return table.concat( | return table.concat(syllables, "·") | ||
end | end | ||