Module:cop-headword

local export = {} local lang = require("Module:languages").getByCode("cop") local m_scripts = require("Module:scripts")

-- key          = what is entered into the template -- first value  = displayed siglum -- second value = tooltip local dialects = { ["A"] = { "A", "Akhmimic" }, ["A2"] = { "L", "Lycopolitan" }, ["B"] = { "B", "Bohairic" }, ["F"] = { "F", "Fayyumic" }, ["G"] = { "G", "Dialect G" }, ["H"] = { "H", "Hermopolitan" }, ["I"] = { "I", "Proto-Lycopolitan" }, ["J"] = { "J", "Dialect J" }, ["K"] = { "K", "Dialect K" }, ["L"] = { "L", "Lycopolitan" }, ["M"] = { "O", "Oxyrhynchite" }, ["O"] = { "O", "Oxyrhynchite" }, ["OC"] = { "OC", "Old Coptic" }, ["P"] = { "P", "Dialect P" }, ["S"] = { "S", "Sahidic" }, }

local rdialects = {} -- allow displayed text forms to be entered too for key, value in pairs(dialects) do	if key == value[1] then rdialects[value[2]] = value end end for key, value in pairs(rdialects) do	dialects[key] = value end

-- expand list of comma-separated dialects (tooltips, etc.) local function parse_dialects(qual) local list = mw.text.split(qual, ',%s*') local expanded = { }

for i, dialect in ipairs(list) do		if dialects[dialect] then table.insert(expanded, '' .. dialects[dialect][1] .. " ") else table.insert(expanded, dialect) end end

return table.concat(expanded, ", ") end

local function generate_head_forms(inflections, name, forms, qualifiers) if #forms < 1 then return end local infl = { label = name } for i, form in ipairs(forms) do		local term = { term = form } if qualifiers[i] then term.q = parse_dialects(qualifiers[i]) end table.insert(infl, term) end table.insert(inflections, infl) end

function export.show_noun(frame) local title = mw.title.getCurrentTitle.text local categories = { } local params = { [1] = { default = "?" },		[2] = { list = "pl", default = title }, [3] = { default = nil }, ["f"] = { list = true }, ["nom"] = { list = true }, ["pro"] = { list = true }, ["q"] = { list = true, require_index = true, allow_holes = true }, ["fq"] = { list = true, require_index = true, allow_holes = true }, ["nomq"] = { list = true, require_index = true, allow_holes = true }, ["proq"] = { list = true, require_index = true, allow_holes = true }, ["head"] = { default = nil }, ["title"] = { default = nil } }	local args = require("Module:parameters").process(frame:getParent.args, params) local plurals = args[2] local head = args["head"] local gender = args[1] local inflections = { ["enable_auto_translit"] = true }

if args[3] and plurals[1] ~= "~" then error("Argument 3 is only allowed if argument 2 is ~ (noun is both countable and uncountable)") elseif plurals[1] == "-" then if #plurals > 1 then error("Cannot provide more plurals for uncountable nouns") end table.insert(inflections, { label = "uncountable" } ) plurals = { } table.insert(categories, "Coptic uncountable nouns") elseif plurals[1] == "!" then if #plurals > 1 then error("Cannot provide more plurals if plural unattested") end table.insert(inflections, { label = "plural not attested" } ) plurals = { } table.insert(categories, "Coptic nouns with unattested plurals") elseif plurals[1] == "~" then table.insert(inflections, { label = "countable and uncountable" } ) plurals[1] = args[3] or head or title table.insert(categories, "Coptic uncountable nouns") -- countable added later end if plurals[1] == "?" or (plurals[1] == "~" and args[3] == "?") then if #plurals > 1 then error("Cannot provide more plurals if the plural is uncertain") end plurals = { } table.insert(categories, "Coptic noun entries missing plural forms") elseif #plurals > 0 then table.insert(categories, "Coptic countable nouns") end if head then for i, pl in ipairs(plurals) do			if pl == title then plurals[i] = head end end end

generate_head_forms(inflections, "feminine", args["f"], args["fq"]) generate_head_forms(inflections, "plural", plurals, args["q"]) generate_head_forms(inflections, "nominal form", args["nom"], args["nomq"]) generate_head_forms(inflections, "pronominal form", args["pro"], args["proq"])

return require("Module:headword").full_headword{ lang = lang, heads = { head or title }, genders = { gender }, inflections = inflections, pos_category = "nouns", categories = categories } end

return export