Module:qay-pron: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 67: Line 67:


local function syllabify(term)
local function syllabify(term)
term = gsub(term, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
local words = mw.text.split(term,"%s")
term = gsub(term, "··", "·"); term = gsub(term, "·$", ""); term = gsub(term, "^·", "")
term = gsub(term, "·(" .. consonants .. ")(" .. consonants .. ")(" .. vowels .. "*)", "%1·%2%3")
term = gsub(term, "·(" .. consonants .. ")$", "%1")
term = gsub(term, "·(" .. consonants .. ")·", "%1·")
term = gsub(term, "(" .. consonants .. ")·(" .. consonants .. ")([pbmvstdnrɾlkɡŋhxçʤʧçx])", "%1%2·%3")
local syllables = split(term, "·");
for _, word in ipairs(words) do
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
if #syllables ~= 1 then
word = gsub(word, "··", "·"); word = gsub(word, "·$", ""); word = gsub(word, "^·", "")
for i, syll in ipairs(syllables) do
word = gsub(word, "·(" .. consonants .. ")(" .. consonants .. ")(" .. vowels .. "*)", "%1·%2%3")
if match(syll, "´") or match(syll, "ː") then
word = gsub(word, "·(" .. consonants .. ")$", "%1")
table.insert(syllables, i, "ˈ")
word = gsub(word, "·(" .. consonants .. ")·", "%1·")
return table.concat(syllables, "·")
word = gsub(word, "(" .. consonants .. ")·(" .. consonants .. ")([pbmvstdnrɾlkɡŋhxçʤʧçx])", "%1%2·%3")
elseif match(term, "ŋ$") 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
ret = table.concat(syllables, "·");
local syllables = split(word, "·");
if not match(ret, "ˈ") then
if #syllables ~= 1 then
syllables = split(ret, "·")
for i, syll in ipairs(syllables) do
syllables[#syllables - 1] = "ˈ" .. syllables[#syllables - 1]
if match(syll, "´") or match(syll, "ː") then
ret = table.concat(syllables, "·")
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
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
end