Modul:la-headword
Bu modul uchun Modul:la-headword/doc nomli hujjat sahifasini yaratishingiz mumkin
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 tili = require("Module:tili").getByCode("la")
-- 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 genders = {}
local inflections = {}
local categories = {"Latin " .. (NAMESPACE == "Reconstruction" and "reconstructed " or "") .. poscat}
local infl_classes = {}
local appendix = {}
if pos_functions[poscat] then
local head2 = pos_functions[poscat](class, args, genders, inflections, categories, infl_classes, appendix)
head = head or head2
end
return
require("Module:headword").full_headword(tili, sc, head, nil, genders, inflections, categories, nil) .. 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, genders, inflections, categories, infl_classes, appendix)
params = {
[1] = {alias_of = 'head'},
[2] = {}, -- Here to prevent an error
[3] = {alias_of = 'gen'},
[4] = {alias_of = 'g'},
[5] = {alias_of = 'decl'},
head = {list = true, default = mw.title.getCurrentTitle().text},
gen = {list = true},
g = {list = true, default = '?'},
decl = {list = true},
indecl = {type = "boolean"},
}
local args = require("Module:parameters").process(args, params)
for _, g in ipairs(args.g) do
if legal_gender[g] then
table.insert(genders, g)
table.insert(categories, "Latin " .. gender_names[g] .. " nouns")
else
error("Gender “" .. g .. "” is not an valid Latin gender.")
end
end
if args.indecl then
table.insert(inflections, {label = "[[Appendix:Glossary#indeclinable|indeclinable]]"})
table.insert(categories, "Latin indeclinable nouns")
for _, g in ipairs(args.g) do
table.insert(categories, "Lotin " .. gender_names[g] .. " indeclinable nouns")
end
else
if #args.decl > 1 then
table.insert(inflections, {label = 'variously declined'})
table.insert(categories, "Latin nouns of 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, "[[Appendix:Latin " .. decl_class .. " declension|" .. decl_class .. " declension]]")
if decl_class ~= "irregular" then
table.insert(categories, "Latin " .. decl_class .. " declension nouns")
end
for _, g in ipairs(args.g) do
table.insert(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(inflections, {label = "no genitive"})
table.insert(categories, "Latin nouns without a genitive singular")
else
args.gen.label = "genitive"
table.insert(inflections, args.gen)
end
end
return args.head
end
pos_functions["proper nouns"] = pos_functions["nouns"]
pos_functions["verbs"] = function(class, args, genders, inflections, categories, 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 = {}
}
local args = require("Module:parameters").process(args,params)
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(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(inflections, args.inf)
if #args.perf > 0 then table.insert(inflections, args.perf) end
if #args.sup > 0 then table.insert(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, "[[Appendix:Latin first conjugation|first conjugation]]")
elseif conj == "2" then
table.insert(appendix, "[[Appendix:Latin second conjugation|second conjugation]]")
elseif conj == "3" then
table.insert(appendix, "[[Appendix:Latin third conjugation|third conjugation]]")
elseif conj == "io" then
table.insert(appendix, "[[Appendix:Latin third conjugation|third conjugation]] iō-variant")
elseif conj == "4" then
table.insert(appendix, "[[Appendix:Latin fourth conjugation|fourth conjugation]]")
elseif conj == "irreg" then --sum
table.insert(appendix, "[[Appendix:Latin irregular verbs|irregular conjugation]]")
else
if NAMESPACE == "Template" then
table.insert(appendix, "? declension")
else
table.insert(categories, "Latin verbs without the conjugation in their headwords")
end
end
if pattern == "impers" then --decet
table.insert(appendix,"[[impersonal#English|impersonal]]")
elseif pattern == "impers-nopass" then --advesperāscit
table.insert(appendix,"[[impersonal#English|impersonal]]")
table.insert(appendix,"no [[passive#English|passive]]")
elseif pattern == "impers-depon" then
table.insert(appendix,"[[impersonal#English|impersonal]]")
table.insert(appendix,"[[deponent#English|deponent]]")
elseif pattern == "depon" then --dēmōlior
table.insert(appendix,"[[deponent#English|deponent]]")
elseif pattern == "semi-depon" then --fido
table.insert(appendix,"[[semi-deponent#English|semi-deponent]]")
elseif pattern == "depon-noperf" then --calvor
table.insert(appendix,"[[deponent#English|deponent]]")
table.insert(appendix,"no [[perfect#English|perfect]]")
elseif pattern == "noperf" then --īnsolēscō
table.insert(appendix,"no [[perfect#English|perfect]]")
elseif pattern == "no-actv-perf" then --interstinguō
table.insert(appendix,"[[defective#English|defective]]")
elseif pattern == "no-pasv-perf" then --ārēscō
table.insert(appendix,"[[defective#English|defective]]")
elseif pattern == "nopass-noperf" then --albēscō
table.insert(appendix,"no [[perfect#English|perfect]] or [[supine#English|supine]] forms")
elseif pattern == "nopass" then --coacēscō
table.insert(appendix,"no [[passive#English|passive]]")
elseif pattern == "pass-3only" then --praefundō
table.insert(appendix,"limited [[passive#English|passive]]")
elseif pattern == "3only-nopass" then --decet
table.insert(appendix,"[[third person#English|third person]] only")
table.insert(appendix,"no [[passive#English|passive]]")
elseif pattern == "pass-impers" then --abambulō
table.insert(appendix,"[[impersonal#English|impersonal]] in the passive")
elseif pattern == "perf-as-pres" then --ōdī
table.insert(appendix,"[[defective#English|defective]]")
elseif pattern == "def" then --āiō
table.insert(appendix,"[[defective#English|defective]]")
elseif pattern == "short-imp" then --dīcō
table.insert(appendix,"irregular short [[imperative#English|imperative]]")
elseif pattern == "facio" then --faciō
table.insert(appendix,"irregular [[passive voice#English|passive voice]]")
elseif pattern == "irreg" then --ferō
table.insert(appendix,"[[irregular#English|irregular]]")
elseif pattern == "noimp" then --no example
--I don't know what to do.
elseif pattern then
table.insert(categories, "la-verb invalid parameters")
end
return args.head
end
pos_functions["adjectives"] = function(class, args, genders, inflections, categories, infl_classes, appendix)
if class == "1&2" or class == "3-3E" then
return pos_functions["adjectives-m-f-n"](class, args, genders, inflections, categories, infl_classes, appendix)
elseif class == "3-1E" then
return pos_functions["adjectives-mfn-gen"](class, args, genders, inflections, categories, infl_classes, appendix)
elseif class == "3-2E" then
return pos_functions["adjectives-mf-n"](class, args, genders, inflections, categories, infl_classes, appendix)
end
end
pos_functions["adjectives-m-f-n"] = function(class, args, genders, inflections, categories, infl_classes, appendix)
params = {
[1] = {alias_of = 'head', required = true},
[2] = {alias_of = 'f', required = true},
[3] = {alias_of = 'n', required = true},
["head"] = {list = true},
["f"] = {list = true},
["n"] = {list = true},
["comp"] = {list = true},
["sup"] = {list = true}
}
local args = require("Module:parameters").process(args, params)
args.f.label = "feminine"
args.n.label = "neuter"
table.insert(genders, "m")
table.insert(inflections, args.f)
table.insert(inflections, args.n)
if #args.comp > 0 then
args.comp.label = "comparative"
table.insert(inflections, args.comp)
end
if #args.sup > 0 then
args.sup.label = "superlative"
table.insert(inflections, args.sup)
end
if class == "1&2" then
table.insert(infl_classes, "[[Appendix:Latin first declension|first]]")
table.insert(infl_classes, "[[Appendix:Latin second declension|second declension]]")
elseif class == "3-3E" then
table.insert(infl_classes, "[[Appendix:Latin third declension|third declension]]")
end
return args.head
end
pos_functions["adjectives-mfn-gen"] = function(class, args, genders, inflections, categories, infl_classes, appendix)
params = {
[1] = {alias_of = 'head', required = true},
[2] = {alias_of = 'gen', required = true},
["head"] = {list = true},
["gen"] = {list = true},
["comp"] = {list = true},
["sup"] = {list = true}
}
local args = require("Module:parameters").process(args, params)
args.gen.label = "genitive"
table.insert(genders, "m")
table.insert(genders, "f")
table.insert(genders, "n")
table.insert(inflections, args.gen)
if #args.comp > 0 then
args.comp.label = "comparative"
table.insert(inflections, args.comp)
end
if #args.sup > 0 then
args.sup.label = "superlative"
table.insert(inflections, args.sup)
end
if class == "3-1E" then
table.insert(infl_classes, "[[Appendix:Latin third declension|third declension]]")
end
return args.head
end
pos_functions["adjectives-mf-n"] = function(class, args, genders, inflections, categories, infl_classes, appendix)
params = {
[1] = {alias_of = 'head', required = true},
[2] = {alias_of = 'n', required = true},
["head"] = {list = true},
["n"] = {list = true},
["comp"] = {list = true},
["sup"] = {list = true}
}
local args = require("Module:parameters").process(args, params)
args.n.label = "neuter"
table.insert(genders, "m")
table.insert(genders, "f")
table.insert(inflections, args.n)
if #args.comp > 0 then
args.comp.label = "comparative"
table.insert(inflections, args.comp)
end
if #args.sup > 0 then
args.sup.label = "superlative"
table.insert(inflections, args.sup)
end
if class == "3-2E" then
table.insert(infl_classes, "[[Appendix:Latin third declension|third declension]]")
end
return args.head
end
return export