Module:qlu-pron: Difference between revisions

No edit summary
No edit summary
Line 67: Line 67:
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"},
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"},
{"ḱ", "kʷ"}, {"ǵ", "ɡʷ"}, {"ʈ", "t"},
{"ḱ", "kʷ"}, {"ǵ", "ɡʷ"}, {"ʈ", "t"},
{"·+", "."}
}
}


local function syllabify(word)
local function syllabify(word)
word = gsub(word, "2", "ˌ")
word = gsub(word, "(ː)(" .. vowels .. ")", "%1·%2")
word = gsub(word, "(ː)(" .. vowels .. ")", "%1·%2")
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
Line 82: Line 83:
local syllables = split(word, "·");
local syllables = split(word, "·");
if #syllables ~= 1 then
if #syllables == 1 then return table.concat(syllables) end -- account for monosyllables
for i, syll in ipairs(syllables) do
for i, syllable in ipairs(syllables) do
if match(word, "´") and not match(syll, "´") then
if match(syllable, "[áéíóúý]") then -- if the user inputted manual stress, ignore all the rest
break
table.insert(syllables, i, "ˈ")
elseif match(syll, "´") then
return table.concat(syllables, "·")
syll = syll:gsub("´","ˈ")
return table.concat(syllables, "·")
elseif 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 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
Line 131: Line 112:
phonetic = gsub(phonetic, rule[1], rule[2])
phonetic = gsub(phonetic, rule[1], rule[2])
end]]
end]]
term = gsub(term, "·", ".")
term = gsub(term, "%.%.", ".")
for _, rule in ipairs(last_rules) do
for _, rule in ipairs(last_rules) do