Module:anui-headword: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 26: | Line 26: | ||
end | end | ||
local function redup(word) | local function redup(word, grave) | ||
word = word:gsub("([ḛḭṵaɔ]" .. TILDEB .. "?)", {["ḛ"] = "è", ["ḭ"] = "ì", ["ṵ"] = "ù", ["a" .. TILDEB] = "à", ["o" .. TILDEB] = "ò"}) | word = word:gsub("([ḛḭṵaɔ]" .. TILDEB .. "?)", {["ḛ"] = "è", ["ḭ"] = "ì", ["ṵ"] = "ù", ["a" .. TILDEB] = "à", ["o" .. TILDEB] = "ò"}) | ||
word = m(word) | word = m(word) | ||
Line 48: | Line 48: | ||
word = word:gsub("ᴍ", "m") | word = word:gsub("ᴍ", "m") | ||
if not | if not grave then | ||
word = word:gsub("[àèìòù]", {["è"] = "ḛ", ["ì"] = "ḭ", ["ù"] = "ṵ", ["à"] = "a" .. TILDEB, ["ò"] = "o" .. TILDEB}) | word = word:gsub("[àèìòù]", {["è"] = "ḛ", ["ì"] = "ḭ", ["ù"] = "ṵ", ["à"] = "a" .. TILDEB, ["ò"] = "o" .. TILDEB}) | ||
end | end | ||
Line 67: | Line 67: | ||
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, args["grave"])}) | ||
if pos == "adverbs" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. pos) end | if pos == "adverbs" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. 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, args["grave"])}) | ||
end | end | ||
Revision as of 13:20, 7 July 2021
- The following documentation is located at Module:anui-headword/doc.[edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local match = mw.ustring.match
local u = mw. ustring.char
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local TILDEB = u(0x0330) -- COMBINING TILDE BELOW ̰◌
local export = {}
local lang = require("Module:languages").getByCode("art-nui")
local deabb = {["adj"] = "adjectives", ["v"] = "verbs", ["adv"] = "adverbs",}
local function glossary_link(entry, text)
text = text or entry
return "[[wikt:Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end
local function m(word)
-- as in [[Module:anui-pron]], account for syllabic m
word = word:gsub("([uùm]ʼ?)m", "%1ᴍ")
word = word:gsub("m(ʼᴍ)", "ᴍ%1")
word = word:gsub("([aeiouàèìòù])m", "%1ᴍ")
word = word:gsub("([aeiouàèìòù])ᴍ([aeiou])", "%1m%2")
return word
end
local function redup(word, grave)
word = word:gsub("([ḛḭṵaɔ]" .. TILDEB .. "?)", {["ḛ"] = "è", ["ḭ"] = "ì", ["ṵ"] = "ù", ["a" .. TILDEB] = "à", ["o" .. TILDEB] = "ò"})
word = m(word)
local consonant = "[ǃǂǁʘʼʇxqrʛɴɬšṣschjklmptŋṉṭṯ]"
local vowel = "[aeiouàèìòùʼãĩõᴍ]"
-- CV > C₁(v)C₂V
local C = match(word, "^" .. vowel .. "?(" .. consonant .. "*)")
local V = match(word, consonant .. "*(" .. vowel .. "*)")
local r = #V == 1 and V or match(word, C .. "(.*)")
local v = sub(V, 1, 1)
local pref = match(C, "[sšṣ]") ~= nil
local nasal = match(C, "ɴ") ~= nil
local glottal = match(C, "[ʇǃǂǁʘṭcɬq]ʼ") ~= 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
elseif uvular then word = gsub(C, "([ʇǃǂǁʘ])x", "%1") .. v .. C .. r
else word = C .. v .. C .. r end
word = word:gsub("ᴍ", "m")
if not grave then
word = word:gsub("[àèìòù]", {["è"] = "ḛ", ["ì"] = "ḭ", ["ù"] = "ṵ", ["à"] = "a" .. TILDEB, ["ò"] = "o" .. TILDEB})
end
return word
end
function export.show(frame)
local args = frame:getParent().args
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]
if f == '-' then
if pos == "adj" then
table.insert(data.inflections, {label = "not " .. glossary_link("comparable")})
table.insert(data.categories, lang:getCanonicalName() .. " uncomparable adjectives")
end
elseif pos ~= "v" then
table.insert(data.inflections, {label = glossary_link("comparative"), redup(word, args["grave"])})
if pos == "adverbs" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. pos) end
else
table.insert(data.inflections, {label = "[[w:applicative voice|applicative]]", redup(word, args["grave"])})
end
return require('Module:headword').full_headword(data)
end
return export