Module:qlu-pron: Difference between revisions

No edit summary
No edit summary
Line 41: Line 41:
local first_rules = {
local first_rules = {
-- vowel digraphs
-- vowel digraphs
{"ăe", "ɛ" .. c.breve}, {"âe", "ɛ" .. c.circ}, {"ae", "ɛ"},
{"ăe", "ɛ" .. c.breve}, {"âe", "ɛ" .. c.circ}, {"áe", "ɛ" .. c.acute}, {"ae", "ɛ"},
{"ău", "ɔ" .. c.breve}, {"âu", "ɔ" .. c.circ}, {"au", "ɔ"},
{"ău", "ɔ" .. c.breve}, {"âu", "ɔ" .. c.circ}, {"áu", "ɔ" .. c.acute}, {"au", "ɔ"},
{"ĕi", "ĭ"}, {"ei", "i"},
{"ĕi", "Ĭ"}, {"êi", "Î"}, {"éi", "Í"}, {"ei", "I"},
-- Graco-Roman digraphs
-- Graco-Roman digraphs
Line 49: Line 49:
{"ch", "k"}, {"g([ckqg])", "ŋ%1"},
{"ch", "k"}, {"g([ckqg])", "ŋ%1"},
{"sc([eêiĭï])", "ʃ%1"}, {"([^ŋ])c([eêiĭï])", "%1ʧ%2"},
{"sc([eêiĭïĬIÎÍ])", "ʃ%1"}, {"([^ŋ])c([eêiĭïĬIÎÍ])", "%1ʧ%2"},
{"g([eêiĭï])", "ʤ%1"}, {"gh", "g"},
{"g([eêiĭïĬIÎÍ])", "ʤ%1"}, {"gh", "g"},
{"c", "k"}, {"ŋʤ", "dʤ"}, {"dz", "ʣ"},
{"c", "k"}, {"ŋʤ", "dʤ"}, {"dz", "ʣ"},
{"ŋgü", "gǵ"}, {"gu(" .. vowels .. ")", "ǵ%1"},
{"ŋgü", "gǵ"}, {"gu(" .. vowels .. ")", "ǵ%1"},
{"gl([iĭï]?)", "ʎ%1"}, {"gn([iĭï]?)", "ɲ%1"},
{"gl([iĭïĬIÎÍ]?)", "ʎ%1"}, {"gn([iĭïĬIÎÍ]?)", "ɲ%1"},
{"(" .. vowels .. ")([ʣʎɲ])(" .. vowels .. ")", "%1%2%2%3"},
{"(" .. vowels .. ")([ʣʎɲ])(" .. vowels .. ")", "%1%2%2%3"},
Line 104: Line 104:
if #syllables == 1 then return table.concat(syllables) end -- account for monosyllables
if #syllables == 1 then return table.concat(syllables) end -- account for monosyllables
local manual_stress = "[áéíóú" .. c.acute .. "]"
local first_stress = "[âêîÎôû" .. c.circ .. "]"
local second_stress = "[áéíÍóú" .. c.acute .. "]"
local unstressed = "[ăĕĭĬŏŭ" .. c.breve .. "]"
for i, syll in ipairs(syllables) do
for i, syll in ipairs(syllables) do
if match(word, manual_stress) and not match(syll, manual_stress) then
if match(word, "ˈ") then -- keep looking for secondary stresses but don't apply penultimate rule
break
if match(syll, second_stress) then
elseif match(syll, manual_stress) then
syll = "ˈ" .. gsub(mw.ustring.toNFD(syll), c.acute, "")
else break end
elseif match(word, first_stress) and not match(syll, first_stress) then
break
elseif match(syll, first_stress) then
syll = "ˈ" .. gsub(mw.ustring.toNFD(syll), c.acute, "")
syll = "ˈ" .. gsub(mw.ustring.toNFD(syll), c.acute, "")
return table.concat(syllables, "·")
return table.concat(syllables, "·")
elseif match(syll, second_stress) then
syll = "ˌ" .. gsub(mw.ustring.toNFD(syll), c.circ, "")
break
elseif match(word, "[ɛɔĬIÎÍ]") then
if match(syll, "[ɛɔI]") and not match(syll, unstressed) then
syll = "ˈ" .. gsub(mw.ustring.toNFD(syll), c.acute, "")
return table.concat(syllables, "·")
end
else
else
table.insert(syllables, #syllables-1, "ˈ")
table.insert(syllables, #syllables-1, "ˈ")