မဝ်ဂျူ:sh-headword
Documentation for this module may be created at မဝ်ဂျူ:sh-headword/doc
local export = {}
local lang = require("Module:languages").getByCode("sh")
local function otherscript(inflections, args)
local title = mw.title.getCurrentTitle()
local sc = lang:findBestScript(title.subpageText)
local other_sc
if sc:getCode() == "Latn" then
other_sc = "Cyrl"
elseif sc:getCode() == "Cyrl" then
other_sc = "Latn"
end
other_sc = require("Module:scripts").getByCode(other_sc)
local inflection = {label = "မလိက်ခ္ဍံက်" .. other_sc:getCanonicalName() }
local heads = args["head"]
if #heads == 0 then
heads = {title.subpageText}
end
if args["tr"][1] == "-" then
inflection.label = "မလိက်ခ္ဍံက်" .. other_sc:getCanonicalName() .. "ပ္ဍဲမပြာကတ်လဝ်ဟွံသေၚ်"
else
for i, head in ipairs(heads) do
local tr = args["tr"][i]
if not tr then
tr = require("Module:sh-translit").tr(require("Module:links").remove_links(head), "sh", sc:getCode())
end
table.insert(inflection, {term = tr, sc = other_sc})
end
end
table.insert(inflections, inflection)
end
local function glossary_link(entry, text)
text = text or entry
return "[[Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end
function export.basic(frame)
local params = {
["head"] = {list = true},
["tr"] = {list = true, allow_holes = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = frame.args[1], categories = {}, heads = args["head"], genders = {}, inflections = {}}
otherscript(data.inflections, args)
return require("Module:headword").full_headword(data)
end
function export.adjective(frame)
local params = {
["def"] = {list = true},
["comp"] = {list = true},
["adv"] = {list = true},
["head"] = {list = true},
["tr"] = {list = true, allow_holes = true},
["indecl"] = {type = "boolean"}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "နာမဝိသေသန", categories = {}, heads = args["head"], genders = {}, inflections = {}}
otherscript(data.inflections, args)
-- Add parameters
local param_list = {
{"def", "definite"},
{"comp", "comparative"},
{"adv", "derived adverb"},
}
if args["indecl"] then
table.insert(data.inflections, {label = glossary_link("ကၞိက်ဟွံမာန်")})
end
for _, val in pairs(param_list) do
local param_name, label = unpack(val)
local forms = args[param_name]
if forms[1] then
forms.label = (param_name == "adv") and label or glossary_link(label)
table.insert(data.inflections, forms)
end
end
return require("Module:headword").full_headword(data)
end
local gender_cats = {
["m"] = "ပုလ္လိၚ်",
["f"] = "ဣတ္တိလိင်",
["n"] = "နပုလ္လိၚ်",
["m-p"] = "ပုလ္လိၚ်",
["f-p"] = "ဣတ္တိလိင်",
["n-p"] = "နပုလ္လိၚ်",
}
function export.letter(frame)
local params = {
["upper"] = {},
["lower"] = {},
["head"] = {list = true},
["tr"] = {list = true, allow_holes = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "အက္ခရ်", categories = {}, heads = args["head"], genders = {}, inflections = {}}
if args["upper"] then
table.insert(data.inflections, {label = "အခဝ်မဍောတ်", nil})
table.insert(data.inflections, {label = "အခဝ်မဇၞော်", args["upper"]})
elseif args["lower"] then
table.insert(data.inflections, {label = "အခဝ်မဇၞော်", nil})
table.insert(data.inflections, {label = "အခဝ်မဍောတ်", args["lower"]})
end
otherscript(data.inflections, args)
return require("Module:headword").full_headword(data)
end
function export.noun(frame)
local params = {
["g"] = {list = true, default = "?"},
["head"] = {list = true},
["tr"] = {list = true, allow_holes = true},
["m"] = {list = true},
["f"] = {list = true},
["dim"] = {list = true},
["aug"] = {list = true},
["adj"] = {list = true},
["indecl"] = {type = "boolean"}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "နာမ်", categories = {}, heads = args["head"], genders = args["g"], inflections = {}}
for i, gender in ipairs(data.genders) do
if gender_cats[gender] then
table.insert(data.categories, "နာမ်" .. gender_cats[gender] .. lang:getCanonicalName() .. "ဂမၠိုင်")
else
data.genders[i] = "?"
end
end
otherscript(data.inflections, args)
-- Add parameters
local param_list = {
{"f", "ဣတ္တိလိင်"},
{"m", "ပုလ္လိၚ်"},
{"dim", "လဟုတ်စှ်ေ"},
{"aug", "ပရေၚ်မဗပေၚ်တိုန်"},
{"adj", "မအဆက်စပ်နာမဝိသေသန"},
}
if args["indecl"] then
table.insert(data.inflections, {label = glossary_link("ကၞိက်ဟွံမာန်")})
end
for _, val in pairs(param_list) do
local param_name, label = unpack(val)
local forms = args[param_name]
if forms[1] then
forms.label = glossary_link(label)
table.insert(data.inflections, forms)
end
end
return require("Module:headword").full_headword(data)
end
function export.propernoun(frame)
local params = {
["g"] = {list = true, default = "?"},
["adj"] = {list = true},
["head"] = {list = true},
["tr"] = {list = true, allow_holes = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "နာမ်မကိတ်ညဳ", categories = {}, heads = args["head"], genders = args["g"], inflections = {}}
for i, gender in ipairs(data.genders) do
if gender_cats[gender] then
table.insert(data.categories, "နာမ်" .. gender_cats[gender] .. lang:getCanonicalName() .. "ဂမၠိုင်")
else
data.genders[i] = "?"
end
end
otherscript(data.inflections, args)
-- Add parameters
local param_list = {
{"adj", "relational adjective"},
}
for _, val in pairs(param_list) do
local param_name, label = unpack(val)
local forms = args[param_name]
if forms[1] then
forms.label = glossary_link(label)
table.insert(data.inflections, forms)
end
end
return require("Module:headword").full_headword(data)
end
function export.verb(frame)
local params = {
["a"] = {},
["head"] = {list = true},
["tr"] = {list = true, allow_holes = true},
["pf"] = {list = true},
["impf"] = {list = true}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "ကြိယာ", categories = {}, heads = args["head"], genders = {}, inflections = {}}
if args["a"] == "impf" or args["a"] == "pf" then
table.insert(data.genders, args["a"])
elseif args["a"] == "impf-pf" or args["a"] == "pf-impf" or args["a"] == "dual" or args["a"] == "ip" then
table.insert(data.genders, "impf")
table.insert(data.genders, "pf")
else
table.insert(data.genders, "?")
end
otherscript(data.inflections, args)
--add perfective equivalent
local pf = args["pf"]
if #pf > 0 then
pf.label = "ဗီုပြၚ်မက္ဍိုပ်ပေၚ်"
table.insert(data.inflections, pf)
end
--add imperfective equivalent
local impf = args["impf"]
if #impf > 0 then
impf.label = "ပါဲဗလေတ်ဟွံမာန်"
table.insert(data.inflections, impf)
end
return require("Module:headword").full_headword(data)
end
return export