Module:qay-pron: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 66: Line 66:
}
}


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


Navigation menu