Module:User:Benwing2/hsb-dsb-headword

Hello, you have come here looking for the meaning of the word Module:User:Benwing2/hsb-dsb-headword. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Benwing2/hsb-dsb-headword, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Benwing2/hsb-dsb-headword in singular and plural. Everything you need to know about the word Module:User:Benwing2/hsb-dsb-headword you have here. The definition of the word Module:User:Benwing2/hsb-dsb-headword will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Benwing2/hsb-dsb-headword, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}
local pos_functions = {}

local function track(page)
	require("Module:debug").track("hsb-dsb-headword/" .. page)
	return true
end

local function glossary_link(entry, text)
	text = text or entry
	return "]"
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local iparams = {
		 = {required = true},
		 = {required = true},
	}

	local iargs = require("Module:parameters").process(frame.args, iparams)
	local poscat = iargs
	langcode = iargs.lang
	if langcode ~= "hsb" and langcode ~= "dsb" then
		error("This module currently only works for lang=hsb and lang=dsb")
	end
	local lang = require("Module:languages").getByCode(langcode)
	local langname = lang:getCanonicalName()

	local params = {
		 = {list = true},
		 = {type = "boolean"},
		 = {type = "boolean", alias_of = "nolink"},
		 = {type = "boolean"},
		 = {type = "boolean"},
		 = {type = "boolean"},
		 = {}, -- for testing
	}

	if pos_functions then
		for key, val in pairs(pos_functions.params) do
			params = val
		end
	end

	local parargs = frame:getParent().args
	local args = require("Module:parameters").process(parargs, params)

	local pagename = args.pagename or mw.title.getCurrentTitle().subpageText

	local user_specified_heads = args.head
	local heads = user_specified_heads
	if args.nolink then
		if #heads == 0 then
			heads = {pagename}
		end
	end

	local data = {
		lang = lang,
		pos_category = poscat,
		categories = {},
		heads = heads,
		user_specified_heads = user_specified_heads,
		no_redundant_head_cat = #user_specified_heads == 0,
		genders = {},
		inflections = {},
		categories = {},
		pagename = pagename,
		id = args.id,
		force_cat_output = force_cat,
	}

	data.is_suffix = false
	if args.suffix or (
		not args.nosuffix and pagename:find("^%-") and poscat ~= "suffixes" and poscat ~= "suffix forms"
	) then
		data.is_suffix = true
		data.pos_category = "suffixes"
		local singular_poscat = require("Module:string utilities").singularize(poscat)
		table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
		table.insert(data.inflections, {label = singular_poscat .. "-forming suffix"})
	end

	if pos_functions then
		pos_functions.func(args, data)
	end

	if args.json then
		return require("Module:JSON").toJSON(data)
	end

	return require("Module:headword").full_headword(data)
end

local genders = {false, "m", "mf", "mfbysense", "f", "n"}
local animacies = {false, "in", "anml", "pr"}
local numbers = {false, "d", "p"}
local allowed_genders = {}

-- Compute allowed genders, and map incomplete genders to specs with a "?" in them.
for _, g in ipairs(genders) do
	for _, an in ipairs(animacies) do
		for _, num in ipairs(numbers) do
			local source_gender_parts = {}
			local dest_gender_parts = {}
			local function ins_part(part, partname)
				if part then
					table.insert(source_gender_parts, part)
					table.insert(dest_gender_parts, part)
				elseif partname == "g" and num == false or partname == "an" then
					-- use ? for incomplete animacy, and also ? for incomplete gender except for duale tantum and
					-- plurale tantum nouns
					table.insert(dest_gender_parts, "?")
				end
			end
			ins_part(g, "g")
			ins_part(an, "an")
			ins_part(num, "num")
			if #source_gender_parts == 0 then
				allowed_genders = "?"
			else
				allowed_genders =
					table.concat(dest_gender_parts, "-")
			end
		end
	end
end

local noun_inflection_specs = {
	{"gen", "genitive singular"},
	{"du", "nominative dual"},
	{"pl", "nominative plural"},
	{"genpl", "genitive plural"},
	{"f", "feminine"},
	{"m", "masculine"},
	{"dim", "diminutive"},
	{"pej", "pejorative"},
	{"aug", "augmentative"},
	{"rel", "related adjective"},
	{"dem", "demonym"},
	{"fdem", "female demonym"},
}

local function get_noun_pos(is_proper)
	local params = {
		 = {type = "boolean"},
		 = {alias_of = "g"},
		 = {list = true},
	}
	for _, spec in ipairs(noun_inflection_specs) do
		local param, desc = unpack(spec)
		params = {list = true, disallow_holes = true}
		params = {list = true, allow_holes = true}
	end

	return {
		params = params,
		func = function(args, data)
			-- Gather genders
			data.genders = args.g

			-- Validate and canonicalize genders
			for i, g in ipairs(data.genders) do
				if not allowed_genders then
					error("Unrecognized " .. langname .. " gender: " .. g)
				else
					data.genders = allowed_genders
				end
			end

			local function process_inflection(label, infls, quals, frob)
				infls.label = label
				for i, infl in ipairs(infls) do
					if frob then
						infl = frob(infl)
					end
					if quals then
						infls = {term = infl, q = {quals}}
					end
				end
				if #infls > 0 then
					table.insert(data.inflections, infls)
				end
			end

			if args.indecl then
				table.insert(data.inflections, {label = glossary_link("indeclinable")})
			end

			-- Process all inflections.
			for _, spec in ipairs(noun_inflection_specs) do
				local param, desc = unpack(spec)
				process_inflection(desc, args, args)
			end
		end
	}
end

pos_functions = get_noun_pos(false)

pos_functions = get_noun_pos(true)

return export