မေႃႇၵျူး:la-headword
Documentation for this module may be created at မေႃႇၵျူး:la-headword/doc
local export = {}
local pos_functions = {}
local legal_gender = {
["m"] = true,
["m-s"] = true,
["m-p"] = true,
["f"] = true,
["f-s"] = true,
["f-p"] = true,
["n"] = true,
["n-s"] = true,
["n-p"] = true,
["c"] = true,
["c-s"] = true,
["c-p"] = true,
["?"] = true,
["?-s"] = true,
["?-p"] = true,
}
local legal_declension = {
["first"] = true,
["second"] = true,
["third"] = true,
["fourth"] = true,
["fifth"] = true,
["irregular"] = true,
}
local gender_names = {
["m"] = "masculine",
["m-s"] = "masculine",
["m-p"] = "masculine",
["f"] = "feminine",
["f-s"] = "feminine",
["f-p"] = "feminine",
["n"] = "neuter",
["n-s"] = "neuter",
["n-p"] = "neuter",
["c"] = "common",
["c-s"] = "common",
["c-p"] = "common",
["?"] = "unknown gender",
["?-s"] = "unknown gender",
["?-p"] = "unknown gender",
}
local lang = require("Module:languages").getByCode("la")
local suffix = nil
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local args = frame:getParent().args
NAMESPACE = mw.title.getCurrentTitle().nsText
PAGENAME = mw.title.getCurrentTitle().text
local head = args["head"]; if head == "" then head = nil end
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local class = frame.args[2]
local suff_type = frame.args.suff_type
local postype = nil
if suff_type then
postype = poscat .. '-' .. suff_type
else
postype = poscat
end
local data = {lang = lang, pos_category = (NAMESPACE == "Reconstruction" and "reconstructed " or "") .. poscat, categories = {}, heads = {head}, genders = {}, inflections = {}}
local infl_classes = {}
local appendix = {}
if poscat == "suffixes" then
table.insert(data.categories, "Latin " .. suff_type .. "-forming suffixes")
suffix = '-'
end
if pos_functions[postype] then
pos_functions[postype](class, args, data, infl_classes, appendix)
end
if suffix then
for i, h in ipairs(data.heads) do
data.heads[i] = suffix .. h
end
end
if mw.ustring.find(mw.ustring.gsub(PAGENAME,"qu","kv"),"[aeiouāēīōū][iu][aeiouāēīōū]") then
table.insert(data.categories, "Kenny's testing category 7")
end
return
require("Module:headword").full_headword(data) .. format(infl_classes,"/") .. format(appendix,", ")
end
function format(array, concatenater)
if #array == 0 then
return ""
else
return "; ''" .. table.concat(array, concatenater) .. "''"
end
end
pos_functions["nouns"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'gen'},
[3] = {alias_of = 'g'},
[4] = {alias_of = 'decl'},
head = {list = true, default = mw.title.getCurrentTitle().text},
gen = {list = true},
g = {list = true, default = '?'},
decl = {list = true},
indecl = {type = "boolean"},
id = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
for _, g in ipairs(args.g) do
if legal_gender[g] then
table.insert(data.genders, g)
table.insert(data.categories, "လႅတ်ႉတိၼ်ႇ " .. gender_names[g] .. " သၢင်ႈ")
else
error("Gender “" .. g .. "” is not an valid Latin gender.")
end
end
if args.indecl then
table.insert(data.inflections, {label = "[[သွႆႉလင်:တီႈပွင်ႇ#indeclinable|indeclinable]]"})
table.insert(data.categories, "Latin indeclinable nouns")
for _, g in ipairs(args.g) do
table.insert(data.categories, "Latin " .. gender_names[g] .. " indeclinable nouns")
end
else
if #args.decl > 1 then
table.insert(data.inflections, {label = 'variously declined'})
table.insert(data.categories, "Latin nouns with multiple declensions")
elseif #args.decl == 0 then
if NAMESPACE == "Template" then
table.insert(appendix, "? declension")
else
error("Please provide the declension class.")
end
end
for _, decl_class in ipairs(args.decl) do
if legal_declension[decl_class] then
table.insert(appendix, "[[သွႆႉလင်:လႅတ်ႉတိၼ်ႇ " .. decl_class .. " declension|" .. decl_class .. " declension]]")
if decl_class ~= "irregular" then
table.insert(data.categories, "Latin " .. decl_class .. " declension nouns")
end
for _, g in ipairs(args.g) do
table.insert(data.categories, "Latin " .. gender_names[g] .. " nouns in the " .. decl_class .. " declension")
end
else
error("Declension “" .. decl_class .. "” is not an legal Latin declension.")
end
end
if #args.gen == 0 then
table.insert(data.inflections, {label = "no genitive"})
table.insert(data.categories, "Latin nouns without a genitive singular")
else
args.gen.label = "genitive"
if suffix then
for i, g in ipairs(args.gen) do
args.gen[i] = suffix .. g
end
end
table.insert(data.inflections, args.gen)
end
end
end
pos_functions["proper nouns"] = pos_functions["nouns"]
pos_functions["suffixes-noun"] = pos_functions["nouns"]
pos_functions["verbs"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'inf'},
[3] = {alias_of = 'perf'},
[4] = {alias_of = 'sup'},
[44] = {default = 'supine'},
head = {list = true},
inf = {list = true},
perf = {list = true},
sup = {list = true},
pattern = {},
c = {alias_of = 'conj'},
conj = {},
id = {},
}
local args = require("Module:parameters").process(args,params)
data.heads = args.head
data.id = args.id
local conj = args.conj
local pattern = args.pattern
args.inf.label = "present infinitive"
args.perf.label = "perfect active"
args.sup.label = args[44]
for i, array in ipairs({args.head, args.inf, args.perf, args.sup}) do
for j, param in ipairs(array) do
if mw.ustring.gsub(param,"^[*a-zA-ZĀāĒēĪīŌōŪūȲȳÄäËëÏïÖöÜü ]+$","") ~= "" then
table.insert(data.categories,"la-verb invalid parameters")
end
if i == 3 then
array[j] = {term = mw.ustring.gsub(param," sum$",""), alt = param}
end
end
end
table.insert(data.inflections, args.inf)
if #args.perf > 0 then table.insert(data.inflections, args.perf) end
if #args.sup > 0 then table.insert(data.inflections, args.sup) end
if #args.perf > 0 and #args.sup == 0 then pattern = pattern or "depon" end
if conj == "1" then
table.insert(appendix, "[[သွႆႉလင်:Latin first conjugation|first conjugation]]")
elseif conj == "2" then
table.insert(appendix, "[[သွႆႉလင်:Latin second conjugation|second conjugation]]")
elseif conj == "3" then
table.insert(appendix, "[[သွႆႉလင်:Latin third conjugation|third conjugation]]")
elseif conj == "io" then
table.insert(appendix, "[[သွႆႉလင်:Latin third conjugation|third conjugation]] iō-variant")
elseif conj == "4" then
table.insert(appendix, "[[သွႆႉလင်:Latin fourth conjugation|fourth conjugation]]")
elseif conj == "irreg" then --sum
table.insert(appendix, "[[သွႆႉလင်:Latin irregular verbs|irregular conjugation]]")
else
if NAMESPACE == "Template" then
table.insert(appendix, "? declension")
else
table.insert(data.categories, "Latin verbs without the conjugation in their headwords")
end
end
if pattern == "impers" then --decet
table.insert(appendix,"[[||impersonal#ဢိင်းၵလဵတ်ႈ|impersonal]]")
elseif pattern == "impers-nopass" then --advesperāscit
table.insert(appendix,"[[||impersonal#ဢိင်းၵလဵတ်ႈ|impersonal]]")
table.insert(appendix,"no [[||passive#ဢိင်းၵလဵတ်ႈ|passive]]")
elseif pattern == "impers-depon" then
table.insert(appendix,"[[||impersonal#ဢိင်းၵလဵတ်ႈ|impersonal]]")
table.insert(appendix,"[[||deponent#ဢိင်းၵလဵတ်ႈ|deponent]]")
elseif pattern == "depon" then --dēmōlior
table.insert(appendix,"[[||deponent#ဢိင်းၵလဵတ်ႈ|deponent]]")
elseif pattern == "semi-depon" then --fido
table.insert(appendix,"[[||semi-deponent#ဢိင်းၵလဵတ်ႈ|semi-deponent]]")
elseif pattern == "depon-noperf" then --calvor
table.insert(appendix,"[[||deponent#ဢိင်းၵလဵတ်ႈ|deponent]]")
table.insert(appendix,"no [[||perfect#ဢိင်းၵလဵတ်ႈ|perfect]]")
elseif pattern == "noperf" then --īnsolēscō
table.insert(appendix,"no [[||perfect#ဢိင်းၵလဵတ်ႈ|perfect]]")
elseif pattern == "no-actv-perf" then --interstinguō
table.insert(appendix,"[[||defective#ဢိင်းၵလဵတ်ႈ|defective]]")
elseif pattern == "no-pasv-perf" then --ārēscō
table.insert(appendix,"[[||defective#ဢိင်းၵလဵတ်ႈ|defective]]")
elseif pattern == "nopass-noperf" then --albēscō
table.insert(appendix,"no [[||perfect#ဢိင်းၵလဵတ်ႈ|perfect]] or [[||supine#ဢိင်းၵလဵတ်ႈ|supine]] forms")
elseif pattern == "nopass" then --coacēscō
table.insert(appendix,"no [[||passive#ဢိင်းၵလဵတ်ႈ|passive]]")
elseif pattern == "pass-3only" then --praefundō
table.insert(appendix,"limited [[||passive#ဢိင်းၵလဵတ်ႈ|passive]]")
elseif pattern == "3only-nopass" then --decet
table.insert(appendix,"[[||third person#ဢိင်းၵလဵတ်ႈ|third person]] only")
table.insert(appendix,"no [[||passive#ဢိင်းၵလဵတ်ႈ|passive]]")
elseif pattern == "pass-impers" then --abambulō
table.insert(appendix,"[[||impersonal#ဢိင်းၵလဵတ်ႈ|impersonal]] in the passive")
elseif pattern == "perf-as-pres" then --ōdī
table.insert(appendix,"[[||defective#ဢိင်းၵလဵတ်ႈ|defective]]")
elseif pattern == "def" then --āiō
table.insert(appendix,"[[||defective#ဢိင်းၵလဵတ်ႈ|defective]]")
elseif pattern == "short-imp" then --dīcō
table.insert(appendix,"irregular short [[||imperative#ဢိင်းၵလဵတ်ႈ|imperative]]")
elseif pattern == "facio" then --faciō
table.insert(appendix,"irregular [[||passive voice#ဢိင်းၵလဵတ်ႈ|passive voice]]")
elseif pattern == "irreg" then --ferō
table.insert(appendix,"[[||irregular#ဢိင်းၵလဵတ်ႈ|irregular]]")
elseif pattern == "noimp" then --no example
--I don't know what to do.
elseif pattern then
table.insert(data.categories, "la-verb invalid parameters")
end
end
pos_functions["adjectives"] = function(class, args, data, infl_classes, appendix)
if class == "1&2" or class == "3-3E" then
pos_functions["adjectives-m-f-n"](class, args, data, infl_classes, appendix)
elseif class == "3-1E" then
pos_functions["adjectives-mfn-gen"](class, args, data, infl_classes, appendix)
elseif class == "3-2E" then
pos_functions["adjectives-mf-n"](class, args, data, infl_classes, appendix)
elseif class == "comp" then
pos_functions["adjectives-comp"](class, args, data, infl_classes, appendix)
elseif class == "sup" then
pos_functions["adjectives-sup"](class, args, data, infl_classes, appendix)
end
end
pos_functions["adjectives-m-f-n"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'f'},
[3] = {alias_of = 'n'},
["head"] = {list = true, required = true},
["f"] = {list = true, required = true},
["n"] = {list = true, required = true},
["comp"] = {list = true},
["sup"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
args.f.label = "feminine"
args.n.label = "neuter"
table.insert(data.inflections, args.f)
table.insert(data.inflections, args.n)
if #args.comp > 0 then
args.comp.label = "comparative"
table.insert(data.inflections, args.comp)
end
if #args.sup > 0 then
args.sup.label = "superlative"
table.insert(data.inflections, args.sup)
end
if class == "1&2" then
table.insert(infl_classes, "[[သွႆႉလင်:Latin first declension|first]]")
table.insert(infl_classes, "[[သွႆႉလင်:Latin second declension|second declension]]")
elseif class == "3-3E" then
table.insert(infl_classes, "[[သွႆႉလင်:Latin third declension|third declension]]")
end
end
pos_functions["adjectives-mfn-gen"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'gen'},
["head"] = {list = true, required = true},
["gen"] = {list = true, required = true},
["comp"] = {list = true},
["sup"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
args.gen.label = "genitive"
table.insert(data.inflections, args.gen)
if #args.comp > 0 then
args.comp.label = "comparative"
table.insert(data.inflections, args.comp)
end
if #args.sup > 0 then
args.sup.label = "superlative"
table.insert(data.inflections, args.sup)
end
if class == "3-1E" then
table.insert(infl_classes, "[[သွႆႉလင်:Latin third declension|third declension]]")
end
end
pos_functions["adjectives-mf-n"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'n'},
["head"] = {list = true, required = true},
["n"] = {list = true, required = true},
["comp"] = {list = true},
["sup"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
args.n.label = "neuter"
table.insert(data.inflections, args.n)
if #args.comp > 0 then
args.comp.label = "comparative"
table.insert(data.inflections, args.comp)
end
if #args.sup > 0 then
args.sup.label = "superlative"
table.insert(data.inflections, args.sup)
end
if class == "3-2E" then
table.insert(infl_classes, "[[သွႆႉလင်:Latin third declension|third declension]]")
end
end
pos_functions["adjectives-comp"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'comp'},
["head"] = {list = true, default = mw.title.getCurrentTitle().text},
["comp"] = {},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
table.insert(data.categories, "Latin comparative adjectives")
table.insert(infl_classes, "[[သွႆႉလင်:Latin third declension|third declension]]")
local n = {label = "neuter"}
for _, head in ipairs(args.head) do
local neuter = mw.ustring.gsub(head, "or$", "us")
table.insert(n, neuter)
end
table.insert(data.inflections, n)
if args.comp then
-- [[ၶိုၵ်ႉတွၼ်း:WhatLinksHere/Template:tracking/la-adj-comparative]]
require("Module:debug").track("la-adj-comparative")
end
end
pos_functions["adjectives-sup"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'sup'},
["head"] = {list = true, default = mw.title.getCurrentTitle().text},
["sup"] = {},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
table.insert(data.categories, "Latin superlative adjectives")
table.insert(infl_classes, "[[သွႆႉလင်:Latin first declension|first]]")
table.insert(infl_classes, "[[သွႆႉလင်:Latin second declension|second declension]]")
local f, n = {label = "feminine"}, {label = "neuter"}
for _, head in ipairs(args.head) do
local stem = mw.ustring.gsub(head, "us$", "")
table.insert(f, stem .. "a")
table.insert(n, stem .. "um")
end
table.insert(data.inflections, f)
table.insert(data.inflections, n)
if args.sup then
-- [[ၶိုၵ်ႉတွၼ်း:WhatLinksHere/Template:tracking/la-adj-superlative]]
require("Module:debug").track("la-adj-superlative")
end
end
pos_functions["adverbs"] = function(class, args, data, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {alias_of = 'comp'},
[3] = {alias_of = 'sup'},
["head"] = {list = true, required = true},
["comp"] = {list = true},
["sup"] = {list = true},
["id"] = {},
}
local args = require("Module:parameters").process(args, params)
data.heads = args.head
data.id = args.id
if #args.comp > 0 and args.comp[1] ~= "-" then
args.comp.label = "[[သွႆႉလင်:တီႈပွင်ႇ#comparative|ဢၼ်ၼိူင်းၵၼ်လႆႈ]]"
table.insert(data.inflections, args.comp)
if #args.sup > 0 and args.sup[1] ~= "-" then
args.sup.label = "[[သွႆႉလင်:တီႈပွင်ႇ#superlative|ဢၼ်ၶႅမ်ႉလိူဝ်သုတ်း]]"
table.insert(data.inflections, args.sup)
else
table.insert(data.inflections, {label = "ဢမ်ႇမီး [[သွႆႉလင်:တီႈပွင်ႇ#superlative|ဢၼ်ၶႅမ်ႉလိူဝ်သုတ်း]]"})
end
table.insert(data.categories, "Latin irregular adverbs")
elseif args.comp[1] == "-" then
table.insert(data.inflections, {label = "[[သွႆႉလင်:တီႈပွင်ႇ#comparative|ဢမ်ႇၼိူင်းၵၼ်လႆႈ]]"})
table.insert(data.categories, "Latin uncomparable adverbs")
else
local comp = {label = "[[သွႆႉလင်:တီႈပွင်ႇ#comparative|ဢၼ်ၼိူင်းၵၼ်လႆႈ]]"}
local sup = {label = "[[သွႆႉလင်:တီႈပွင်ႇ#superlative|ဢၼ်ၶႅမ်ႉလိူဝ်သုတ်း]]"}
for _, head in ipairs(args.head) do
local stem = nil
for _, suff in ipairs({"iter", "nter", "ter", "er", "iē", "ē", "im", "ō"}) do
stem = mw.ustring.match(head, "(.*)" .. suff .. "$")
if stem ~= nil then
if suff == "nter" then
stem = stem .. "nt"
suff = "er"
end
table.insert(comp, stem .. "ius")
table.insert(sup, stem .. "issimē")
break
end
end
if not stem then
error("Unrecognized adverb type, recognized types are “-ē”, “-er”, “-ter”, “-iter”, “-im”, or “-ō” or specify irregular forms or “-” if incomparable.")
end
end
table.insert(data.inflections, comp)
if args.sup[1] ~= '-' then
table.insert(data.inflections, sup)
else
table.insert(data.inflections, {label = "ဢမ်ႇမီး [[သွႆႉလင်:တီႈပွင်ႇ#superlative|ဢၼ်ၶႅမ်ႉလိူဝ်သုတ်း]]"})
table.insert(data.categories, "Latin irregular adverbs")
end
end
end
return export