Module:qay-pron: Difference between revisions

Created page with "local sub = mw.ustring.sub local find = mw.ustring.find local gmatch = mw.ustring.gmatch local gsub = mw.ustring.gsub local match = mw.ustring.match local u = mw.ustring.char..."
 
No edit summary
Line 21: Line 21:
local vowels = "[aeiouyáéíóúýàèìòùỳː" .. NONSYLLABIC .. DIPHTHONG .. "]"
local vowels = "[aeiouyáéíóúýàèìòùỳː" .. NONSYLLABIC .. DIPHTHONG .. "]"


local rules = {
local phonemic_rules = {
{"rh", ""}, {"mh", "m"}, {"th", "θ"}, {"lj", "ʎ"}, {"ñ", "ɲ"}, {"kh", "x"}, {"[gɡ]h", "ɣ"}, {"g", "ɡ"},
{"mh", "m"},
}
{"([aāáà][eo])", "%1" .. NONSYLLABIC}, {"([iíuú])([aāeēoōáéóàèò])", "%1" .. DIPHTHONG .. "%2"},
 
{"ā", "aː"}, {"ē", "eː"}, {"ī", "iː"}, {"ō", "oː"}, {"ū", "uː"}, {"ȳ", "yː"},
local phonetic_rules = {
{"à", "áː"}, {"è", "éː"}, {"ì", "íː"}, {"ò", "óː"}, {"ù", "úː"}, {"ỳ", "ýː"},
{"mh", "m"}, {"th", "θ"}, {"lj", "ʎ"}, {"ñ", "ɲ"}, {"kh", "x"}, {"[gɡ]h", "ɣ"}, {"g", "ɡ"},
{"n([" .. palatal .. "])", "ɲ%1"}, {"n([" .. velar .. "])", "ŋ%1"}, {"n([" .. uvular .. "])", "ɴ%1"},
{"(" .. vowels .. ")r(" .. vowels .. ")", "%1ɾ%2"}, {"ɲi", "ni"}, {"ʎi", "li"},
}
}


Line 36: Line 33:
}
}


function export.write_stress(term, from_module)
local function write_stress(term)
local pattern = "(" .. consonants .. "*".. vowels .. "*" .. consonants .. "-)"
--[=[local pattern = "(" .. consonants .. "*".. vowels .. "*" .. consonants .. "-)"
local weight = {}
local weight = {}
term = gsub(term, pattern, "·%1")
term = gsub(term, pattern, "·%1")
Line 71: Line 68:
else table.insert(syllables, #syllables-1, "ˈ") end
else table.insert(syllables, #syllables-1, "ˈ") end
return table.concat(syllables)
return table.concat(syllables)]=]
return term
end
end


function export.crux(term)
function export.phonemic(term)
term = mw.ustring.lower(term)
term = mw.ustring.lower(term)
for _, rule in ipairs(rules) do
for _, micrule in ipairs(phonemic_rules) do
term = gsub(term, rule[1], rule[2])
term = gsub(term, micrule[1], micrule[2])
end
end
return export.write_stress(term, false)
return write_stress(term)
end
end


function export.antique_crux(term)
function export.phonetic(term)
local oldrules = {
term = mw.ustring.lower(term)
{"v([ou])", "w%1"}, {"v([ay])", "ɥ%1"}, {"(" .. vowels .. ")v(ˈ?" .. consonants .. ")", "%1u%2"},
{"j([iy])", "ɟ%1"}, {"sˈ?ri(".. vowels .. ")", "ˈɟ%1"}, {"sr", "ɟ"}, {"sˈ?r", "ˈɟ"},
}
term = export.crux(term)
for _, oldrule in ipairs(oldrules) do
for _, ticrule in ipairs(phonetic_rules) do
term = gsub(term, oldrule[1], oldrule[2])
term = gsub(term, ticrule[1], ticrule[2])
end
end
return term
return write_stress(term)
end
end