မဝ်ဂျူ:kmr-headword
မံက်ပြာကတ်
local export = {}
local pos_functions = {}
local m_scripts = require("Module:scripts")
local en_utilities_module = "Module:en-utilities"
local lang = require("Module:languages").getByCode("kmr")
local langname = lang:getCanonicalName()
local ku_sc = m_scripts.getByCode("ku-Arab")
local PAGENAME = mw.loadData("Module:headword/data").pagename
local boolean = {type = "boolean"}
local list = {list = true}
local suffix_categories = {
["နာမဝိသေသန"] = true,
["ကြိယာဝိသေသန"] = true,
["နာမ်"] = true,
["ကြိယာ"] = true,
}
local function track(page)
require("Module:debug").track("kmr-headword/" .. page)
return true
end
local function glossary_link(entry, text)
text = text or entry
return "[[အဆက်လက္ကရဴ:မသောၚ်ကၠးဝေါဟာ#" .. entry .. "|" .. text .. "]]"
end
local function process_arabic_spellings(spellings)
local inflection = {}
for _, spelling in ipairs(spellings) do
table.insert(inflection, {term = spelling, sc = ku_sc})
end
inflection.label = "ခ္ဍံက်လိက်အာရဗဳ"
return inflection
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local tracking_categories = {}
local poscat = frame.args[1]
or error("Plural part of speech e.g. 'nouns' has not been specified. Please pass parameter 1 to the module invocation.")
local params = {
["head"] = list,
["tr"] = {list = true, allow_holes = true},
["id"] = {},
["ar"] = list,
["suff"] = boolean,
["c"] = boolean,
}
if pos_functions[poscat] then
for key, val in pairs(pos_functions[poscat].params) do
params[key] = val
end
end
local parargs = frame:getParent().args
local args = require("Module:parameters").process(parargs, params)
local data = {
lang = lang,
pos_category = poscat,
categories = {},
heads = args["head"],
translits = args["tr"],
genders = {},
inflections = {},
id = args["id"],
categories = {}
}
if args["suff"] then
data.pos_category = "အဆက်လက္ကရဴ"
if suffix_categories[poscat] then
local singular_poscat = poscat:gsub("s$", "")
-- table.insert(data.categories, singular_poscat .. " " .. singular_poscat .. "-forming suffixes")
else
error("No category exists for suffixes forming " .. poscat .. ".")
end
end
if pos_functions[poscat] then
pos_functions[poscat].func(args, data, tracking_categories)
end
if #args["ar"] > 0 then
table.insert(data.inflections, process_arabic_spellings(args["ar"]))
end
return require("Module:headword").full_headword(data)
.. require("Module:utilities").format_categories(tracking_categories, lang)
end
pos_functions["ကြိယာ"] = {
params = {
[1] = {},
[2] = {},
},
func = function(args, data, tracking_categories)
if args[1] then
table.insert(data.inflections, {label = "ကာလပစ္စုပ္ပန်ကိုန်ဨကဝုစ်နကဵုပူဂဵုတတိယ", args[1], accel = {form = '3|s|pres'}})
end
if args[2] then
table.insert(data.inflections, {label = "ကာလအတိက်", args[2], accel = {form = 'past'}})
end
end
}
pos_functions["နာမဝိသေသန"] = {
params = {
[1] = {alias_of = "ပတဝ်ပတုပ်ရံၚ်", list = false},
["ပတဝ်ပတုပ်ရံၚ်"] = list, --comparative(s)
[2] = {alias_of = "superlative", list = false},
["သဒ္ဒာ"] = list, --superlative(s)
["c"] = boolean,
},
func = function(args, data, tracking_categories)
if args.comparative[1] == "-" then
table.insert(data.inflections, {label = "ပတဝ်ပတုပ်ရံၚ်ဟွံမာန်"})
table.insert(data.categories, "နာမဝိသေသန" .. langname .. "မဂၠာဲပတုပ်ရံၚ်ဟွံမာန်ဂမၠိုၚ်")
else
if #args.comparative > 0 then
args.comparative.label = glossary_link("ပတဝ်ပတုပ်ရံၚ်")
args.comparative.accel = {form = "ပတဝ်ပတုပ်ရံၚ်"}
table.insert(data.inflections, args.comparative)
else
if args["c"] then
table.insert(data.inflections, {label = glossary_link("ပတဝ်ပတုပ်ရံၚ်"), accel = {form = 'comparative'}, {term = PAGENAME ..'tir'}})
end
end
if #args.superlative > 0 then
args.superlative.label = glossary_link("သဒ္ဒာ")
args.superlative.accel = {form = "သဒ္ဒာ"}
table.insert(data.inflections, args.superlative)
else
if args["c"] then
table.insert(data.inflections, {label = glossary_link("သဒ္ဒာ"), accel = {form = 'superlative'}, {term = '[[herî]] ' .. PAGENAME}, {term = '[[tewrî]] ' .. PAGENAME}})
end
end
end
end
}
local noun_params = {
[1] = {alias_of = "g", list = false},
["g"] = list, --gender(s)
[2] = {alias_of = "pl", list = false},
["pl"] = list, --plural(s)
["f"] = list, --feminine form(s)
["m"] = list, --masculine form(s)
}
local allowed_genders = {
["m"] = true,
["f"] = true,
["n"] = true,
["mf"] = true,
["mfbysense"] = true,
["m-p"] = true,
["f-p"] = true,
["n-p"] = true,
}
local function do_nouns(pos, args, data, tracking_categories)
local genders = {}
for _, g in ipairs(args.g) do
if not allowed_genders[g] then
error("Unrecognized gender: " .. g)
end
if g == "mf" then
table.insert(genders, "m")
table.insert(genders, "f")
else
table.insert(genders, g)
end
end
if #genders > 0 then
data.genders = genders
else
data.genders = {"?"}
end
local plpos = require(en_utilities_module).pluralize(pos)
-- Check for special plural signals
local mode = nil
if args.pl[1] == "?" or args.pl[1] == "!" or args.pl[1] == "-" or args.pl[1] == "-~" or args.pl[1] == "~" or args.pl[1] == "#" then
mode = args.pl[1]
table.remove(args.pl, 1) -- Remove the mode parameter
end
if mode == "?" then
-- Plural is unknown
table.insert(data.categories, plpos .. langname .. "မနွံကဵုကိုန်ဗဟုဝစ်ဟွံတီကၠး ဝါ ဟွံချိုတ်ပၠိုတ်ဂမၠိုၚ်")
elseif mode == "!" then
-- Plural is not attested
table.insert(data.inflections, {label = "ကိုန်ဗဟုဝစ်ဟွံစုတ်လဝ်ဒုၚ်ရပ်စပ်"})
table.insert(data.categories, plpos .. langname .. "မနွံကဵုကိုန်ဗဟုဝစ်ညးဂှ်လေဝ်ဟွံစုတ်မဒုၚ်ရပ်စပ်ဂမၠိုၚ်")
return
elseif mode == "-" then
-- Uncountable noun; may occasionally have a plural
table.insert(data.categories, plpos .. langname .. "မတော်ဟွံဂွံဂမၠိုၚ်")
table.insert(data.inflections, {label = glossary_link("မတော်ဟွံမာန်")})
elseif mode == "-~" then
table.insert(data.categories, plpos .. langname .. "မတော်ဟွံဂွံဂမၠိုၚ်")
table.insert(data.inflections, {label = "ဗွဲတၟေၚ်" .. glossary_link("မတော်ဟွံမာန်")})
elseif mode == "~" then
-- Mixed countable/uncountable noun, always has a plural
table.insert(data.inflections, {label = glossary_link("မတော်မာန်") .. " and " .. glossary_link("မတော်ဟွံမာန်")})
table.insert(data.categories, plpos .. langname .. "မတော်ဟွံဂွံဂမၠိုၚ်")
table.insert(data.categories, plpos .. langname .. "မတော်ဂွံဂမၠိုၚ်")
elseif mode == "#" or pos == "နာမ်" then
-- Countable nouns; the default for regular nouns but not proper nouns
if mode == "#" then
table.insert(data.inflections, {label = glossary_link("မတော်မာန်")})
end
-- Not enough nouns properly use - in the second argument
-- table.insert(data.categories, plpos .. langname .. "မတော်ဂွံဂမၠိုၚ်")
end
if #args.pl > 0 then
args.pl.label = "ကိုန်ဗဟုဝစ်"
args.pl.accel = {form = "p"}
table.insert(data.inflections, args.pl)
end
if #args.f > 0 then
args.f.label = "ဣတ္တိလိၚ်"
table.insert(data.inflections, args.f)
end
if #args.m > 0 then
args.m.label = "ပုလ္လိၚ်"
table.insert(data.inflections, args.m)
end
end
pos_functions["နာမ်"] = {
params = noun_params,
func = function(args, data, tracking_categories)
return do_nouns("နာမ်", args, data, tracking_categories)
end,
}
pos_functions["နာမ်မကိတ်ညဳ"] = {
params = noun_params,
func = function(args, data, tracking_categories)
return do_nouns("နာမ်မကိတ်ညဳ", args, data, tracking_categories)
end,
}
return export