45,645
edits
No edit summary |
No edit summary |
||
Line 67: | Line 67: | ||
local function syllabify(term) | local function syllabify(term) | ||
local words = mw.text.split(term,"%s") | |||
for _, word in ipairs(words) do | |||
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 not match(ret, "ˈ") then | 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 | |||
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 | ||