Module:mwl-headword

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

This module is used for Mirandese headword-line templates.

The module is always invoked the same way, by passing a single parameter to the "show" function. This parameter is the name of the part of speech, but in plural (examples given are for nouns, and for adjective forms respectively):

{{#invoke:mwl-headword|show|nouns}}

The template will, by default, accept the following parameters (specific parts of speech may accept or require others):

|head=
Override the headword display, used to add links to individual words in a multi-word term.
|cat=
Override the default category, which is the same as the provided parameter.

--[=[
Based on ]
]=]

local export = {}
local pos_functions = {}

local force_cat = false -- for testing; if true, categories appear in non-mainspace pages

local rfind = mw.ustring.find
local rmatch = mw.ustring.match
local require_when_needed = require("Module:utilities/require when needed")

local m_table = require("Module:table")
local com = require("Module:mwl-common")

local en_utilities_module = "Module:en-utilities"
local headword_module = "Module:headword"
local headword_utilities_module = "Module:headword utilities"
local inflection_utilities_module = "Module:inflection utilities"
local romut_module = "Module:romance utilities"

local m_en_utilities = require_when_needed(en_utilities_module)
local m_headword_utilities = require_when_needed(headword_utilities_module)
local m_string_utilities = require_when_needed("Module:string utilities")
local glossary_link = require_when_needed(headword_utilities_module, "glossary_link")

local lang = require("Module:languages").getByCode("mwl")
local langname = lang:getCanonicalName()

local rsub = com.rsub
local usub = mw.ustring.sub

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

local list_param = {list = true, disallow_holes = true}
local boolean_param = {type = "boolean"}

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local poscat = frame.args
		or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")

	local parargs = frame:getParent().args

	local params = {
		 = list_param,
		 = {},
		 = boolean_param,
		 = boolean_param,
		 = boolean_param,
		 = {}, -- for testing
	}

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

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

	local pagename = args.pagename or mw.loadData("Module:headword/data").pagename

	local user_specified_heads = args.head
	local heads = user_specified_heads
	if args.nolinkhead then
		if #heads == 0 then
			heads = {pagename}
		end
	else
		local romut = require(romut_module)
		local auto_linked_head = romut.add_links_to_multiword_term(pagename, args.splithyph)
		if #heads == 0 then
			heads = {auto_linked_head}
		else
			for i, head in ipairs(heads) do
				if head:find("^~") then
					head = romut.apply_link_modifiers(auto_linked_head, usub(head, 2))
					heads = head
				end
			end
		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 = {},
		pagename = pagename,
		id = args.id,
		force_cat_output = force_cat,
	}

	local is_suffix = false
	if pagename:find("^%-") and poscat ~= "suffix forms" then
		is_suffix = true
		data.pos_category = "suffixes"
		local singular_poscat = m_en_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, frame, is_suffix)
	end

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

	return require(headword_module).full_headword(data)
end

-----------------------------------------------------------------------------------------
--                                     Utility functions                               --
-----------------------------------------------------------------------------------------

local function replace_hash_with_lemma(term, lemma)
	-- If there is a % sign in the lemma, we have to replace it with %% so it doesn't get interpreted as a capture
	-- replace expression.
	lemma = m_string_utilities.replacement_escape(lemma)
	return (term:gsub("#", lemma)) -- discard second retval
end


-- Parse and insert an inflection not requiring additional processing into `data.inflections`. The raw arguments come
-- from `args`, which is parsed for inline modifiers. `label` is the label that the inflections are given;
-- `plpos` is the plural part of speech, used in ].
-- `accel` is the accelerator form, or nil.
local function parse_and_insert_inflection(data, args, field, label, plpos, accel)
	m_headword_utilities.parse_and_insert_inflection {
		headdata = data,
		forms = args,
		paramname = field,
		label = label,
		accel = accel and {form = accel} or nil,
		check_missing = true,
		lang = lang,
		plpos = plpos,
	}
end


-- Insert default plurals generated when a given plural had the value of + and default plurals were fetched as a result.
-- `plobj` is the parsed object whose `term` field is "+". `defpls` is the list of default plurals. `dest` is the list
-- into which the plurals are inserted (which inherit their qualifiers and labels from `plobj`).
local function insert_defpls(defpls, plobj, dest)
	if not defpls then
		-- Happens e.g. with ] where the default plural algorithm returns nothing.
		return
	end
	if #defpls == 1 then
		plobj.term = defpls
		table.insert(dest, plobj)
	else
		for _, defpl in ipairs(defpls) do
			local newplobj = m_table.shallowCopy(plobj)
			newplobj.term = defpl
			table.insert(dest, newplobj)
		end
	end
end

-----------------------------------------------------------------------------------------
--                                       Adjectives                                    --
-----------------------------------------------------------------------------------------

local function do_adjective(args, data, pos, is_suffix, is_superlative)
	local feminines = {}
	local masculine_plurals = {}
	local feminine_plurals = {}
	if is_suffix then
		pos = "suffix"
	end
	local plpos = m_en_utilities.pluralize(pos)

	if not is_suffix then
		data.pos_category = plpos
	end

	if args.sp then
		local romut = require(romut_module)
		if not romut.allowed_special_indicators then
			local indicators = {}
			for indic, _ in pairs(romut.allowed_special_indicators) do
				table.insert(indicators, "'" .. indic .. "'")
			end
			table.sort(indicators)
			error("Special inflection indicator beginning can only be " ..
				mw.text.listToText(indicators) .. ": " .. args.sp)
		end
	end

	local lemma = data.pagename

	local function fetch_inflections(field)
		local retval = m_headword_utilities.parse_term_list_with_modifiers {
			paramname = field,
			forms = args,
		}
		if not retval then
			return {{term = "+"}}
		end
		return retval
	end

	local function insert_inflection(terms, label, accel)
		m_headword_utilities.insert_inflection {
			headdata = data,
			terms = terms,
			label = label,
			accel = accel and {form = accel} or nil,
			check_missing = true,
			lang = lang,
			plpos = plpos,
		}
	end

	if args.inv then
		-- invariable adjective
		table.insert(data.inflections, {label = glossary_link("invariable")})
		table.insert(data.categories, langname .. " indeclinable " .. plpos)
		if args.sp or args.f or args.pl or args.mpl or args.fpl then
			error("Can't specify inflections with an invariable " .. pos)
		end
	elseif args.fonly then
		-- feminine-only
		if args.f then
			error("Can't specify explicit feminines with feminine-only " .. pos)
		end
		if args.pl then
			error("Can't specify explicit plurals with feminine-only " .. pos .. ", use fpl=")
		end
		if args.mpl then
			error("Can't specify explicit masculine plurals with feminine-only " .. pos)
		end
		local argsfpl = fetch_inflections("fpl")
		for _, fpl in ipairs(argsfpl) do
			if fpl.term == "+" then
				-- Generate default feminine plural.
				local defpls = com.make_plural(lemma, args.sp)
				if not defpls then
					error("Unable to generate default plural of '" .. lemma .. "'")
				end
				insert_defpls(defpls, fpl, feminine_plurals)
			else
				fpl.term = replace_hash_with_lemma(fpl.term, lemma)
				table.insert(feminine_plurals, fpl)
			end
		end

		table.insert(data.inflections, {label = "feminine-only"})
		insert_inflection(feminine_plurals, "feminine plural", "f|p")
	else
		-- Gather feminines.
		for _, f in ipairs(fetch_inflections("f")) do
			if f.term == "+" then
				-- Generate default feminine.
				f.term = com.make_feminine(lemma, args.sp)
			else
				f.term = replace_hash_with_lemma(f.term, lemma)
			end
			table.insert(feminines, f)
		end

		local fem_like_lemma = #feminines == 1 and feminines.term == lemma and
			not m_headword_utilities.termobj_has_qualifiers_or_labels(feminines)
		if fem_like_lemma then
			table.insert(data.categories, langname .. " epicene " .. plpos)
		end

		local mpl_field = "mpl"
		local fpl_field = "fpl"
		if args.pl then
			if args.mpl or args.fpl then
				error("Can't specify both pl= and mpl=/fpl=")
			end
			mpl_field = "pl"
			fpl_field = "pl"
		end
		local argsmpl = fetch_inflections(mpl_field)
		local argsfpl = fetch_inflections(fpl_field)

		for _, mpl in ipairs(argsmpl) do
			if mpl.term == "+" then
				-- Generate default masculine plural.
				local defpls = com.make_plural(lemma, args.sp)
				if not defpls then
					error("Unable to generate default plural of '" .. lemma .. "'")
				end
				insert_defpls(defpls, mpl, masculine_plurals)
			else
				mpl.term = replace_hash_with_lemma(mpl.term, lemma)
				table.insert(masculine_plurals, mpl)
			end
		end

		for _, fpl in ipairs(argsfpl) do
			if fpl.term == "+" then
				for _, f in ipairs(feminines) do
					-- Generate default feminine plural; f is a table.
					local defpls = com.make_plural(f.term, args.sp)
					if not defpls then
						error("Unable to generate default plural of '" .. f.term .. "'")
					end
					for _, defpl in ipairs(defpls) do
						local fplobj = m_table.shallowCopy(fpl)
						fplobj.term = defpl
						m_headword_utilities.combine_termobj_qualifiers_labels(fplobj, f)
						table.insert(feminine_plurals, fplobj)
					end
				end
			else
				fpl.term = replace_hash_with_lemma(fpl.term, lemma)
				table.insert(feminine_plurals, fpl)
			end
		end

		parse_and_insert_inflection(data, args, "mapoc", "masculine singular before a noun", plpos)

		local fem_pl_like_masc_pl = masculine_plurals and feminine_plurals and
			m_table.deepEquals(masculine_plurals, feminine_plurals)
		local masc_pl_like_lemma = #masculine_plurals == 1 and masculine_plurals.term == lemma and
			not m_headword_utilities.termobj_has_qualifiers_or_labels(masculine_plurals)
		if fem_like_lemma and fem_pl_like_masc_pl and masc_pl_like_lemma then
			-- actually invariable
			table.insert(data.inflections, {label = glossary_link("invariable")})
			table.insert(data.categories, langname .. " indeclinable " .. plpos)
		else
			-- Make sure there are feminines given and not same as lemma.
			if not fem_like_lemma then
				insert_inflection(feminines, "feminine", "f|s")
			else
				data.genders = {"mf"}
			end

			if fem_pl_like_masc_pl then
				insert_inflection(masculine_plurals, "masculine and feminine plural", "p")
			else
				insert_inflection(masculine_plurals, "masculine plural", "m|p")
				insert_inflection(feminine_plurals, "feminine plural", "f|p")
			end
		end
	end

	parse_and_insert_inflection(data, args, "comp", "comparative", plpos)
	parse_and_insert_inflection(data, args, "sup", "superlative", plpos)
	parse_and_insert_inflection(data, args, "dim", "diminutive", plpos)
	parse_and_insert_inflection(data, args, "aug", "augmentative", plpos)

	if args.irreg and is_superlative then
		table.insert(data.categories, langname .. " irregular superlative " .. plpos)
	end
end


local function get_adjective_params(adjtype)
	local params = {
		 = boolean_param, --invariable
		 = {}, -- special indicator: "first", "first-last", etc.
	}
	local function ins_infl(field)
		params = list_param --feminine form(s)
	end

	ins_infl("f") -- feminine form(s)
	ins_infl("pl") -- plural override(s)
	ins_infl("mpl") -- masculine plural override(s)
	ins_infl("fpl") -- feminine plural override(s)

	if adjtype == "base" then
		ins_infl("comp") --comparative(s)
		ins_infl("sup") --superlative(s)
		ins_infl("dim") --diminutive(s)
		ins_infl("aug") --augmentative(s)
		params = boolean_param -- feminine only
		params = {} -- has comparative
	end
	if adjtype == "sup" then
		params = boolean_param
	end
	return params
end

-- Display additional inflection information for an adjective
pos_functions = {
	params = get_adjective_params("base"),
	func = function(args, data, frame, is_suffix)
		do_adjective(args, data, "adjective", is_suffix, false)
	end
}

pos_functions = {
	params = get_adjective_params("part"),
	func = function(args, data, frame, is_suffix)
		do_adjective(args, data, "participle", is_suffix, false)
		data.pos_category = "past participles"
	end,
}

pos_functions = {
	params = get_adjective_params("det"),
	func = function(args, data, frame, is_suffix)
		do_adjective(args, data, "determiner", is_suffix, false)
	end
}

pos_functions = {
	params = get_adjective_params("pron"),
	func = function(args, data, frame, is_suffix)
		do_adjective(args, data, "pronoun", is_suffix, false)
	end
}

pos_functions = {
	params = get_adjective_params("comp"),
	func = function(args, data, frame, is_suffix)
		do_adjective(args, data, "adjective", is_suffix, false)
	end
}

pos_functions = {
	params = get_adjective_params("sup"),
	func = function(args, data, frame, is_suffix)
		do_adjective(args, data, "adjective", is_suffix, true)
	end
}

-----------------------------------------------------------------------------------------
--                                         Adverbs                                     --
-----------------------------------------------------------------------------------------

pos_functions = {
	params = {
		 = list_param, --superlative(s)
	},
	func = function(args, data)
		parse_and_insert_inflection(data, args, "sup", "superlative", "adverbs")
	end,
}

-----------------------------------------------------------------------------------------
--                                        Numerals                                     --
-----------------------------------------------------------------------------------------

pos_functions = {
	params = {
		 = list_param, --feminine(s)
	},
	func = function(args, data)
		local plpos = "numerals"
		data.pos_category = plpos
		table.insert(data.categories, 1, langname .. " cardinal numbers")

		if args.f then
			table.insert(data.genders, "m")
			parse_and_insert_inflection(data, args, "f", "feminine", plpos)
		end
	end,
}

-----------------------------------------------------------------------------------------
--                                          Nouns                                      --
-----------------------------------------------------------------------------------------

local allowed_genders = require("Module:table").listToSet(
	{"m", "f", "mf", "mfbysense", "mfequiv", "n", "m-p", "f-p", "mf-p", "mfbysense-p", "mfequiv-p", "n-p", "?", "?-p"}
)


local function process_genders(data, genders, g_qual)
	for i, g in ipairs(genders) do
		if not allowed_genders then
			error("Unrecognized gender: " .. g)
		end
		if g_qual then
			table.insert(data.genders, {spec = g, qualifiers = {g_qual}})
		else
			table.insert(data.genders, g)
		end
	end
end

-- Display additional inflection information for a noun
local function do_noun(args, data, pos, is_suffix)
	local is_plurale_tantum = false
	local has_singular = false
	if is_suffix then
		pos = "suffix"
	end
	local plpos = m_en_utilities.pluralize(pos)

	data.genders = {}
	local saw_m = false
	local saw_f = false
	local gender_for_irreg_ending, gender_for_make_plural
	process_genders(data, args, args.g_qual)
	-- Check for specific genders and pluralia tantum.
	for _, g in ipairs(args) do
		if g:find("-p$") then
			is_plurale_tantum = true
		else
			has_singular = true
			if g == "m" or g == "mf" or g == "mfbysense" then
				saw_m = true
			end
			if g == "f" or g == "mf" or g == "mfbysense" then
				saw_f = true
			end
		end
	end
	if saw_m and saw_f then
		gender_for_irreg_ending = "mf"
	elseif saw_f then
		gender_for_irreg_ending = "f"
	else
		gender_for_irreg_ending = "m"
	end
	gender_for_make_plural = gender_for_irreg_ending

	local lemma = data.pagename

	local plurals = {}

	if is_plurale_tantum and not has_singular then
		if args then
			error("Can't specify plurals of plurale tantum " .. pos)
		end
		table.insert(data.inflections, {label = glossary_link("plural only")})
	else
		plurals = m_headword_utilities.parse_term_list_with_modifiers {
			paramname = {2, "pl"},
			forms = args,
		}
		-- Check for special plural signals
		local mode = nil

		local pl1 = plurals
		if pl1 and #pl1.term == 1 then
			mode = pl1.term
			if mode == "?" or mode == "!" or mode == "-" or mode == "~" then
				pl1.term = nil
				if next(pl1) then
					error(("Can't specify inline modifiers with plural code '%s'"):format(mode))
				end
				table.remove(plurals, 1)  -- Remove the mode parameter
			elseif mode ~= "+" and mode ~= "#" then
				error(("Unexpected plural code '%s'"):format(mode))
			end
		end

		if mode == "?" then
			-- Plural is unknown
			table.insert(data.categories, langname .. " " .. plpos .. " with unknown or uncertain plurals")
		elseif mode == "!" then
			-- Plural is not attested
			table.insert(data.inflections, {label = "plural not attested"})
			table.insert(data.categories, langname .. " " .. plpos .. " with unattested plurals")
			if plurals then
				error("Can't specify any plurals along with unattested plural code '!'")
			end
		elseif mode == "-" then
			-- Uncountable noun; may occasionally have a plural
			table.insert(data.categories, langname .. " uncountable " .. plpos)

			-- If plural forms were given explicitly, then show "usually"
			if plurals then
				table.insert(data.inflections, {label = "usually " .. glossary_link("uncountable")})
				table.insert(data.categories, langname .. " countable " .. plpos)
			else
				table.insert(data.inflections, {label = glossary_link("uncountable")})
			end
		else
			-- Countable or mixed countable/uncountable
			if not plurals then
				plurals = {term = "+"}
			end
			if mode == "~" then
				-- Mixed countable/uncountable noun, always has a plural
				table.insert(data.inflections, {label = glossary_link("countable") .. " and " .. glossary_link("uncountable")})
				table.insert(data.categories, langname .. " uncountable " .. plpos)
				table.insert(data.categories, langname .. " countable " .. plpos)
			else
				-- Countable nouns
				table.insert(data.categories, langname .. " countable " .. plpos)
			end
		end

		-- Gather plurals, handling requests for default plurals.
		local has_default_or_hash = false
		for _, pl in ipairs(plurals) do
			if pl.term:find("^%+") or pl.term:find("#") then
				has_default_or_hash = true
				break
			end
		end
		if has_default_or_hash then
			local newpls = {}
			for _, pl in ipairs(plurals) do
				if pl.term == "+" then
					local default_pls = com.make_plural(lemma)
					insert_defpls(default_pls, pl, newpls)
				elseif pl.term:find("^%+") then
					pl.term = require(romut_module).get_special_indicator(pl.term)
					local default_pls = com.make_plural(lemma, pl.term)
					insert_defpls(default_pls, pl, newpls)
				else
					pl.term = replace_hash_with_lemma(pl.term, lemma)
					table.insert(newpls, pl)
				end
			end
			plurals = newpls
		end
	end

	if #plurals > 1 then
		table.insert(data.categories, langname .. " " .. plpos .. " with multiple plurals")
	end

	-- Gather masculines/feminines. For each one, generate the corresponding plural(s). `field` is the name of the
	-- field containing the masculine or feminine forms (normally "m" or "f"); `gender` is "m" or "f" for the gender
	-- of the forms; `inflect` is a function of one or two arguments to generate the default masculine or feminine from
	-- the lemma (the arguments are the lemma and optionally a "special" flag to indicate how to handle multiword
	-- lemmas, and the function is normally make_feminine or make_masculine from ]); and
	-- `default_plurals` is a list into which the corresponding default plurals of the gathered or generated masculine
	-- or feminine forms are stored. Note that there may be more default plurals than masculines or feminines, because
	-- some terms have multiple possible plurals.
	local function handle_mf(field, gender, inflect, default_plurals)
		local mfs = m_headword_utilities.parse_term_list_with_modifiers {
			paramname = field,
			forms = args,
			frob = function(term)
				if term == "+" then
					-- Generate default masculine/feminine.
					term = inflect(lemma)
				else
					term = replace_hash_with_lemma(term, lemma)
				end
				local special = require(romut_module).get_special_indicator(term)
				if special then
					term = inflect(lemma, special)
				end
				return term
			end
		}
		for _, mf in ipairs(mfs) do
			local mfpls = com.make_plural(mf.term, special)
			if mfpls then
				for _, mfpl in ipairs(mfpls) do
					local plobj = m_table.shallowCopy(mf)
					plobj.term = mfpl
					-- Add an accelerator for each masculine/feminine plural whose lemma
					-- is the corresponding singular, so that the accelerated entry
					-- that is generated has a definition that looks like
					-- # {{plural of|es|MFSING}}
					plobj.accel = {form = "p", lemma = mf.term}
					table.insert(default_plurals, plobj)
				end
			end
		end
		return mfs
	end

	local feminine_plurals = {}
	local feminines = handle_mf("f", "f", com.make_feminine, feminine_plurals)
	local masculine_plurals = {}
	local masculines = handle_mf("m", "m", com.make_masculine, masculine_plurals)

	local function handle_mf_plural(mfplfield, gender, default_plurals, singulars)
		local mfpl = m_headword_utilities.parse_term_list_with_modifiers {
			paramname = mfplfield,
			forms = args,
		}
		local new_mfpls = {}
		local saw_plus
		for i, mfpl in ipairs(mfpl) do
			local accel
			if #mfpl == #singulars then
				-- If same number of overriding masculine/feminine plurals as singulars,
				-- assume each plural goes with the corresponding singular
				-- and use each corresponding singular as the lemma in the accelerator.
				-- The generated entry will have # {{plural of|es|SINGULAR}} as the
				-- definition.
				accel = {form = "p", lemma = singulars.term}
			else
				accel = nil
			end
			if mfpl.term == "+" then
				-- We should never see + twice. If we do, it will lead to problems since we overwrite the values of
				-- default_plurals the first time around.
				if saw_plus then
					error(("Saw + twice when handling %s="):format(mfplfield))
				end
				saw_plus = true
				for _, defpl in ipairs(default_plurals) do
					-- defpl is already a table and has an accel field
					m_headword_utilities.combine_termobj_qualifiers_labels(defpl, mfpl)
					table.insert(new_mfpls, defpl)
				end
			elseif mfpl.term:find("^%+") then
				mfpl.term = require(romut_module).get_special_indicator(mfpl.term)
				for _, mf in ipairs(singulars) do
					local default_mfpls = com.make_plural(mf.term, mfpl.term)
					for _, defp in ipairs(default_mfpls) do
						local mfplobj = m_table.shallowCopy(mfpl)
						mfplobj.term = defp
						mfplobj.accel = accel
						m_headword_utilities.combine_termobj_qualifiers_labels(mfplobj, mf)
						table.insert(new_mfpls, mfplobj)
					end
				end
			else
				mfpl.accel = accel
				mfpl.term = replace_hash_with_lemma(mfpl.term, lemma)
				table.insert(new_mfpls, mfpl)
			end
		end
		return new_mfpls
	end

	if args.fpl then
		-- Override any existing feminine plurals.
		feminine_plurals = handle_mf_plural("fpl", "f", feminine_plurals, feminines)
	end

	if args.mpl then
		-- Override any existing masculine plurals.
		masculine_plurals = handle_mf_plural("mpl", "m", masculine_plurals, masculines)
	end

	local function parse_and_insert_noun_inflection(field, label, accel)
		parse_and_insert_inflection(data, args, field, label, plpos, accel)
	end

	local function insert_noun_inflection(terms, label, accel)
		m_headword_utilities.insert_inflection {
			headdata = data,
			terms = terms,
			label = label,
			accel = accel and {form = accel} or nil,
			check_missing = true,
			lang = lang,
			plpos = plpos,
		}
	end

	insert_noun_inflection(plurals, "plural", "p")
	insert_noun_inflection(feminines, "feminine", "f")
	insert_noun_inflection(feminine_plurals, "feminine plural")
	insert_noun_inflection(masculines, "masculine")
	insert_noun_inflection(masculine_plurals, "masculine plural")
	parse_and_insert_noun_inflection("dim", "diminutive")
	parse_and_insert_noun_inflection("aug", "augmentative")
	parse_and_insert_noun_inflection("pej", "pejorative")
	
	--[=[
	-- Maybe add category 'Mirandese nouns with irregular gender'
	local irreg_gender_lemma = rsub(lemma, " .*", "") -- only look at first word
	if (rfind(irreg_gender_lemma, "o$") and (gender_for_irreg_ending == "f" or gender_for_irreg_ending == "mf")) or
		(irreg_gender_lemma:find("a$") and (gender_for_irreg_ending == "m" or gender_for_irreg_ending == "mf")) then
		table.insert(data.categories, langname .. " nouns with irregular gender")
	end
	]=]

end

local function get_noun_params(is_proper)
	return {
		 = {list = "g", required = not is_proper, default = "?"}, --gender
		 = {list = "g\1_qual", allow_holes = true},
		 = {list = "pl"}, --plural override(s)
		 = list_param, --feminine form(s)
		 = list_param, --masculine form(s)
		 = list_param, --feminine plural override(s)
		 = list_param, --masculine plural override(s)
		 = list_param, --diminutive(s)
		 = list_param, --diminutive(s)
		 = list_param, --pejorative(s)
	}
end

pos_functions = {
	params = get_noun_params(),
	func = function(args, data, frame, is_suffix)
		do_noun(args, data, "noun", is_suffix)
	end,
}

pos_functions = {
	params = get_noun_params("is proper"),
	func = function(args, data, frame, is_suffix)
		do_noun(args, data, "noun", is_suffix, "is proper")
	end,
}

-----------------------------------------------------------------------------------------
--                                      Phrases                                        --
-----------------------------------------------------------------------------------------

pos_functions = {
	params = {
		 = list_param,
		 = {list = "g\1_qual", allow_holes = true},
		 = list_param,
		 = list_param,
	},
	func = function(args, data)
		data.genders = {}
		process_genders(data, args.g, args.g_qual)
		local plpos = "phrases"
		parse_and_insert_inflection(data, args, "m", "masculine", plpos)
		parse_and_insert_inflection(data, args, "f", "feminine", plpos)
	end,
}

-----------------------------------------------------------------------------------------
--                                    Suffix forms                                     --
-----------------------------------------------------------------------------------------

pos_functions = {
	params = {
		 = {required = true, list = true, disallow_holes = true},
		 = list_param,
		 = {list = "g\1_qual", allow_holes = true},
	},
	func = function(args, data)
		data.genders = {}
		process_genders(data, args.g, args.g_qual)
		local suffix_type = {}
		for _, typ in ipairs(args) do
			table.insert(suffix_type, typ .. "-forming suffix")
		end
		table.insert(data.inflections, {label = "non-lemma form of " .. require("Module:table").serialCommaJoin(suffix_type, {conj = "or"})})
	end,
}

return export