မဝ်ဂျူ:mk-headword
မံက်ပြာကတ်
Documentation for this module may be created at မဝ်ဂျူ:mk-headword/doc
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("mk")
local langname = lang:getCanonicalName()
local rfind = mw.ustring.find
local rsubn = mw.ustring.gsub
-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
local retval = rsubn(term, foo, bar)
return retval
end
local function make_entry_name(head)
return lang:makeEntryName(require("Module:links").remove_links(head))
end
local function track(page)
require("Module:debug").track("mk-headword/" .. page)
return true
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local NAMESPACE = mw.title.getCurrentTitle().nsText
local PAGENAME = mw.title.getCurrentTitle().text
local tracking_categories = {}
local iparams = {
[1] = {required = true},
["def"] = {},
["suff_type"] = {},
}
local iargs = require("Module:parameters").process(frame.args, iparams)
local args = frame:getParent().args
local poscat = iargs[1]
local def = iargs.def
local suff_type = iargs.suff_type
local postype = nil
if suff_type then
postype = poscat .. '-' .. suff_type
else
postype = poscat
end
local data = {lang = lang, categories = {}, heads = {}, genders = {}, inflections = {}}
if poscat == "suffixes" then
end
if pos_functions[postype] then
local new_poscat = pos_functions[postype](postype, def, args, data)
if new_poscat then
poscat = new_poscat
end
end
for _, head in ipairs(data.heads) do
if rfind(head, "[́̀ѐѝ]") then
track("accents")
end
end
if not rfind(poscat, " forms?$") then
for _, head in ipairs(data.heads) do
-- Don't trigger on prefixes, suffixes or reflexive verbs.
if (rfind(head, " ") or rfind(head, ".%-.")) and not rfind(head, "^се [^ ]+$") then
break
end
end
end
for _, inflection_set in ipairs(data.inflections) do
for _, inflection in ipairs(inflection_set) do
local title = mw.title.new(make_entry_name(inflection))
if title and not title.exists then
end
end
end
data.pos_category = (NAMESPACE == "Reconstruction" and "reconstructed " or "") .. poscat
return require("Module:headword").full_headword(data)
.. require("Module:utilities").format_categories(tracking_categories, lang)
end
pos_functions["ကြိယာ"] = function(postype, def, args, data)
local params = {
["head"] = {list = true},
[1] = {},
["pf"] = {list = true},
["impf"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
local cats = {}
data.heads = args.head
data.id = args.id
if args[1] == "pf" then
data.genders = {"pf"}
cats = {}
elseif args[1] == "impf" then
data.genders = {"impf"}
cats = {}
elseif args[1] == "both" then
data.genders = {"impf", "pf"}
cats = {}
elseif args[1] == "?" or not args[1] then
data.genders = {"?"}
else
error("Unrecognized aspect '" .. args[1] .. "'")
end
for _, cat in ipairs(cats) do
end
local pf = args.pf
if #pf == 1 and pf[1] == "-" then
table.insert(data.inflections, {label = "ဗီုပြၚ်မက္ဍိုပ်ပေၚ်ဟွံသေၚ်"})
elseif #pf > 0 then
pf.label = "ဗီုပြၚ်မက္ဍိုပ်ပေၚ်"
table.insert(data.inflections, pf)
end
local impf = args.impf
if #impf == 1 and impf[1] == "-" then
table.insert(data.inflections, {label = "ဟွံဆေၚ်ကဵုပါဲဗလေတ်ဟွံမာန်"})
elseif #impf > 0 then
impf.label = "ပါဲဗလေတ်ဟွံမာန်"
table.insert(data.inflections, impf)
end
end
local function nouns(pos, def, args, data)
local params = {
["head"] = {list = true},
[1] = {list = "g"},
[2] = {list = "pl"},
[3] = {alias_of = "dim"},
["dim"] = {list = true},
["m"] = {list = true},
["f"] = {list = true},
["adj"] = {list = true},
["aug"] = {list = true},
["indecl"] = {type = "boolean"},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
local genders = {}
local cat2 = nil
for _, g in ipairs(args[1]) do
if g == "m" or g == "m-p" then
elseif g == "f" or g == "f-p" then
elseif g == "n" or g == "n-p" then
elseif g ~= "p" and g ~= "?" then
error("Unrecognized gender: '" .. g .. "'")
end
if g == "m-p" or g == "f-p" or g == "n-p" or g == "p" then
end
table.insert(genders, g)
end
if #genders == 0 then
genders = {"?"}
end
if cat2 then
table.insert(data.categories, cat2)
end
if #genders > 1 then
end
data.genders = genders
if args.indecl then
table.insert(data.inflections, {label = "ကၞိက်ဟွံမာန်"})
end
local pl = args[2]
if #pl == 1 and pl[1] == "-" then
table.insert(data.inflections, {label = "တော်ဟွံမာန်"})
elseif #pl > 0 then
pl.label = "ကိုန်ဗဟုဝစ်"
table.insert(data.inflections, pl)
end
local m = args.m
if #m > 0 then
m.label = "ပုလ္လိၚ်"
table.insert(data.inflections, m)
end
local f = args.f
if #f > 0 then
f.label = "ဣတ္တိလိင်"
table.insert(data.inflections, f)
end
local adj = args.adj
if #adj > 0 then
adj.label = "မဆေၚ်စပ်ကဵုနာမဝိသေသန"
table.insert(data.inflections, adj)
end
local dim = args.dim
if #dim == 1 and dim[0] == "-" then
table.insert(data.inflections, {label = "လဟုတ်စှ်ေဟွံသေၚ်"})
elseif #dim > 0 then
dim.label = "diminutive"
table.insert(data.inflections, dim)
end
local aug = args.aug
if #aug == 1 and aug[0] == "-" then
table.insert(data.inflections, {label = "အရာဗပေၚ်စုတ်လဝ်ဟွံသေၚ်"})
elseif #aug > 0 then
aug.label = "augmentative"
table.insert(data.inflections, aug)
end
data.id = args.id
end
pos_functions["နာမ်"] = nouns
pos_functions["နာမ်မကိတ်ညဳ"] = nouns
local function adverbs(pos, def, args, data)
local params = {
["head"] = {list = true},
[1] = {list = "comp"},
[2] = {list = "sup"},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
local comp = args[1]
if comp[1] == "-" then
table.insert(data.inflections, {label = "ပတုပ်ရံၚ်ဟွံမာန်"})
else
local head
if #data.heads > 0 then
head = make_entry_name(data.heads[1])
else
head = mw.title.getCurrentTitle().text
end
if #comp == 0 then
comp = {"по" .. head}
end
comp.label = "ပတုပ်ရံၚ်"
table.insert(data.inflections, comp)
local sup = args[2]
if #sup == 0 then
sup = {"нај" .. head}
end
sup.label = "သဒ္ဒာ"
table.insert(data.inflections, sup)
end
data.id = args.id
end
pos_functions["ကြိယာဝိသေသန"] = adverbs
local function adjectives(pos, def, args, data)
local params = {
["head"] = {list = true},
[1] = {list = "comp"},
[2] = {list = "sup"},
["indecl"] = {type = "boolean"},
["dim"] = {list = true},
["adv"] = {list = true},
["absn"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
if args.indecl then
table.insert(data.inflections, {label = "ကၞိက်ဟွံမာန်"})
end
local comp = args[1]
if comp[1] == "-" then
table.insert(data.inflections, {label = "ပတုပ်ရံၚ်ဟွံမာန်"})
else
local head
if #data.heads > 0 then
head = make_entry_name(data.heads[1])
else
head = mw.title.getCurrentTitle().text
end
if #comp == 0 then
comp = {"по" .. head}
end
comp.label = "ပတုပ်ရံၚ်"
table.insert(data.inflections, comp)
local sup = args[2]
if #sup == 0 then
sup = {"нај" .. head}
end
sup.label = "သဒ္ဒာ"
table.insert(data.inflections, sup)
end
local dim = args.dim
if #dim > 0 then
dim.label = "လဟုတ်စှ်ေ"
table.insert(data.inflections, dim)
end
local adv = args.adv
if #adv > 0 then
adv.label = "ကြိယာဝိသေသန"
table.insert(data.inflections, adv)
end
local absn = args.absn
if #absn > 0 then
absn.label = "abstract noun"
table.insert(data.inflections, absn)
end
data.id = args.id
end
pos_functions["နာမဝိသေသန"] = adjectives
pos_functions["determiners"] = adjectives
pos_functions["သဗ္ဗနာမ်"] = adjectives
pos_functions["suffixes-adjective"] = function(postype, def, args, data)
return adjectives("suffixes", def, args, data)
end
pos_functions["numerals-adjective"] = function(postype, def, args, data)
return adjectives("numerals", def, args, data)
end
pos_functions["participles"] = function(pos, def, args, data)
local params = {
["head"] = {list = true},
[1] = {required = true, list = true, default = "aor"},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
for _, part in ipairs(args[1]) do
if part == "adv" then
elseif part == "aor" then
elseif part == "impf" then
elseif part == "pres" then
elseif part == "pass" or part == "ppp" then
elseif part == "prespass" then
else
error("Unrecognized participle type '" .. part .. "': Should be adv, aor, impf, pres, pass or prespass")
end
end
end
pos_functions["phrases"] = function(postype, def, args, data)
local params = {
["head"] = {list = true, default = def},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
end
local function non_lemma_forms(postype, def, args, data)
local params = {
["head"] = {list = true, default = def},
["g"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.genders = args.g
data.id = args.id
if postype == "participle forms" or postype == "verbal nouns" then
elseif postype == "verbal noun forms" then
return "noun forms"
end
end
pos_functions["ဗီုပြင်နာမ်"] = non_lemma_forms
pos_functions["ဗီုပြင်နာမ်မကိတ်ညဳ"] = non_lemma_forms
pos_functions["ဗီုပြင်သဗ္ဗနာမ်"] = non_lemma_forms
pos_functions["ဗီုပြင်ကြိယာ"] = non_lemma_forms
pos_functions["verbal nouns"] = non_lemma_forms
pos_functions["verbal noun forms"] = non_lemma_forms
pos_functions["ဗီုပြင်နာမဝိသေသန"] = non_lemma_forms
pos_functions["participle forms"] = non_lemma_forms
pos_functions["determiner forms"] = non_lemma_forms
pos_functions["ဗီုပြင်ဂၞန်သင်္ချာ"] = non_lemma_forms
pos_functions["suffix forms"] = non_lemma_forms
return export