Module:anui-headword: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
local match = mw.ustring.match
local match = mw.ustring.match
local u = mw. ustring.char
local u = mw.ustring.char
local gsub = mw.ustring.gsub
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local sub = mw.ustring.sub
Line 15: Line 15:
return "[[wikt:Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
return "[[wikt:Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end
end
local consonant = "[ǃǂǁʘʼʇxqrʛɴɬšṣschjklmptŋṉṭṯ]"
local vowel = "[aeiouàèìòùãĩõũḛḭṵ" .. TILDEB .. "v@]"


local function m(word)
local function m(word)
-- as in [[Module:anui-pron]], account for syllabic m
word = word:gsub("mʼm", "v")
word = word:gsub("([uùm]ʼ?)m", "%1ᴍ")
word = word:gsub("(" .. vowel .. ")m", "%")
word = word:gsub("m(ʼᴍ)", "%1")
word = word:gsub("(" .. vowel .. "*)@(" .. vowel .. "*)", "%1@%2")
word = word:gsub("([aeiouàèìòù])m", "%1ᴍ")
word = word:gsub("([aeiouàèìòù])ᴍ([aeiou])", "%1m%2")
return word
return word
Line 27: Line 28:


local function redup(word)
local function redup(word)
word = word:gsub("([ḛḭṵaɔ]" .. TILDEB .. "?)", {["ḛ"] = "è", ["ḭ"] = "ì", ["ṵ"] = "ù", ["a" .. TILDEB] = "à", ["o" .. TILDEB] = "ò"})
word = m(word)
word = m(word)
 
local consonant = "[ǃǂǁʘʼʇxqrʛɴɬšṣschjklmptŋṉṭṯ]"
local vowel = "[aeiouàèìòùʼãĩõᴍ]"
-- CV > C₁(v)C₂V
-- CV > C₁(v)C₂V
local C = match(word, "^" .. vowel .. "?(" .. consonant .. "*)")
local C = match(word, "^" .. vowel .. "?(" .. consonant .. "*)")
local V = match(word, consonant .. "*(" .. vowel .. "*)")
local V = mw.ustring.toNFD(match(word, consonant .. "*(" .. vowel .. "*)"))
local r = #V == 1 and V or match(word, C .. "(.*)")
V = V:gsub("ḛ", "e"); V = V:gsub("ḭ", "i"); V = V:gsub("ṵ", "u"); V = V:gsub("v", "u")
local r2 = match(word, C .. "(.*)")
local v = sub(V, 1, 1)
local v = sub(V, 1, 1)
local pref = match(C, "[sšṣ]") ~= nil
local ejective = C == "tɬʼ" or match(C, "^[ṭcq]ʼ$") ~= nil
local fricative = match(C, "[sšṣɬ][ʇǃǂǁʘ]") ~= nil
local nasal = match(C, "ɴ") ~= nil
local nasal = match(C, "ɴ") ~= nil
local glottal = match(C, "[ʇǃǂǁʘṭcɬq]ʼ") ~= nil
local glottal = match(C, "[ʇǃǂǁʘṭcɬq]ʼ") ~= nil
local uvular = match(C, "x") ~= nil
local uvular = match(C, "x") ~= nil
if (nasal or pref) or glottal then word = C .. (glottal and "" or v) .. gsub(C, "[sšṣ]([ʇǃǂǁʘ])", "%1") .. r
if ejective then word = C .. C .. r2
elseif uvular then word = gsub(C, "([ʇǃǂǁʘ])x", "%1") .. v .. C .. r
elseif (nasal or fricative) or glottal then word = C .. (glottal and "" or v) .. gsub(C, "[sšṣɬ]([ʇǃǂǁʘ])", "%1") .. r2
else word = C .. v .. C .. r end
elseif uvular then word = gsub(C, "([ʇǃǂǁʘ])x", "%1") .. v .. C .. r2
else word = C .. v .. C .. r2 end
word = word:gsub("", "m")
word = word: gsub("v", "mʼm"); word = word:gsub("ũ", "m"); word = word:gsub("@", "ʼ")
if not args["grave"] then
word = word:gsub("[àèìòù]", {["è"] = "ḛ", ["ì"] = "", ["ù"] = "ṵ", ["à"] = "a" .. TILDEB, ["ò"] = "o" .. TILDEB})
end
return word
return word
Line 58: Line 57:
local args = frame:getParent().args
local args = frame:getParent().args
local word = args["w"] or mw.title.getCurrentTitle().text
local word = args["w"] or mw.title.getCurrentTitle().text
local data = {lang = lang, pos_category = deabb[args[1]], heads = {word}, categories = {}, inflections = {},}
local pos = args[1]; local f = args[2]
local pos = args[1]; local f = args[2]
local data = {lang = lang, pos_category = deabb[pos], heads = {word}, categories = {}, inflections = {},}
if f == '-' then
if f == '-' then
if pos == "adj" then
if pos == "adj" then
table.insert(data.inflections, {label = "not " .. glossary_link("comparable")})
table.insert(data.inflections, {label = "not " .. glossary_link("comparable")})
table.insert(data.categories, lang:getCanonicalName() .. " uncomparable adjectives")
table.insert(data.categories, lang:getCanonicalName() .. " uncomparable " .. deabb[pos])
end
end
elseif pos ~= "v" then
elseif pos ~= "v" then
table.insert(data.inflections, {label = glossary_link("comparative"), redup(word)})
table.insert(data.inflections, {label = glossary_link("comparative"), redup(word)})
if pos == "adverbs" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. pos) end
if pos == "adv" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. deabb[pos]) end
else
else
table.insert(data.inflections, {label = "[[w:applicative voice|applicative]]", redup(word)})
table.insert(data.inflections, {label = "[[w:applicative voice|applicative]]", redup(word)})