Module:qay-pron: Difference between revisions

No edit summary
No edit summary
Line 31: Line 31:


local function same(foo, bar)
local function same(foo, bar)
foo, bar = match(foo, "^."), match(bar, "^.")
foo, bar = mw.ustring.toNFD(foo), mw.ustring.toNFD(bar) -- decompose diacritics
foo, bar = match(foo, "^."), match(bar, "^.") -- sort out the letter
return foo == bar and true or false
return foo == bar and true or false
end
end
Line 43: Line 44:


local phonemic_rules = {
local phonemic_rules = {
{"([tkdɡ])j", "%1ʲ"}, {"(" .. consonants .. consonants .. ")", function(c1, c2) return same(c1,c2) and c1 or c1 .. c2 end},
{"([tkdɡ])j", "%1ʲ"}, {"(" .. consonants .. ")(" .. consonants .. ")", function(c1, c2) return same(c1,c2) and c1 or c1 .. c2 end},
}
}


Line 55: Line 56:
}
}


local function syllabify(term, pos)
local function syllabify(term)
term = gsub(term, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
term = gsub(term, "(" .. consonants .. "*)(" .. vowels .. "*)", "%1%2·")
term = gsub(term, "··", "·"); term = gsub(term, "·$", "")
term = gsub(term, "··", "·"); term = gsub(term, "·$", "")
Line 63: Line 64:
local syll = split(term, "·"); local noa = {}
local syll = split(term, "·"); local noa = {}
local monosyll = {["n"] = "ˈ", ["pron"] = "", ["particle"] = "(ˈ)", ["prep"] = "(ˈ)", ["conj"] = "(ˈ)"}
if #syll ~= 1 then
if #syll ~= 1 then
Line 77: Line 76:
end
end


return table.concat(#noa > 1 and noa or syll, "·")
return table.concat(#noa > 1 and noa or syll, ".")
end
end


function export.phonemic(term)
function export.phonemic(term)
term = mw.ustring.lower(term)
term = mw.ustring.lower(term)
term = syllabify(term)
for _, rule in ipairs(shared_rules) do
for _, rule in ipairs(shared_rules) do
Line 96: Line 96:
function export.phonetic(term)
function export.phonetic(term)
term = mw.ustring.lower(term)
term = mw.ustring.lower(term)
term = syllabify(term)
for _, rule in ipairs(shared_rules) do
for _, rule in ipairs(shared_rules) do