Modul:fr-headword

Üdvözlöm, Ön a Modul:fr-headword szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:fr-headword szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:fr-headword szót egyes és többes számban mondani. Minden, amit a Modul:fr-headword szóról tudni kell, itt található. A Modul:fr-headword szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:fr-headword és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:fr-headword/doc lapon tudod dokumentálni

local export = {}
local pos_functions = {}
local rfind = mw.ustring.find
local rmatch = mw.ustring.match
local rsubn = mw.ustring.gsub
local rsplit = mw.text.split

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

local suffix_categories = {
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
}

local prepositions = {
	"à ",
	"aux? ",
	"d ",
	"d",
	"des ",
	"en ",
	"sous ",
	"sur ",
	"avec ",
	"pour ",
	"par ",
	"dans ",
	"contre ",
	"sans ",
	"comme ",
	"jusqu",
	-- We could list others but you get diminishing returns
}

-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end

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

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

-- mw.title.new() returns nil if there are weird chars in the pagename.
local function exists(pagename)
	local title = mw.title.new(pagename)
	return title and title.exists
end

local function check_exists(forms, cats, pos)
	for _, form in ipairs(forms) do
		if type(form) == "table" then
			form = form.term
		end
		if not exists(form) then
			table.insert(cats, langname .. " " .. pos .. " piros linket tartalmazó fejsorral")
			return false
		end
	end
	return true
end

local function make_plural(form, special)
	local retval = require("Module:romance utilities").handle_multiword(form, special, make_plural, prepositions)
	if retval then
		if #retval > 1 then
			error("Internal error: Got multiple plurals from handle_multiword(): " .. table.concat(retval))
		end
		return retval
	end

	if rfind(form, "$") then
		return form
	elseif rfind(form, "au$") then
		return form .. "x"
	elseif rfind(form, "al$") then
		return rsub(form, "al$", "aux")
	else
		return form .. "s"
	end
end

local function make_feminine(form, special)
	local retval = require("Module:romance utilities").handle_multiword(form, special, make_feminine, prepositions)
	if retval then
		if #retval > 1 then
			error("Internal error: Got multiple feminines from handle_multiword(): " .. table.concat(retval))
		end
		return retval
	end

	if rfind(form, "e$") then
		return form
	elseif rfind(form, "en$") then
		return form .. "ne"
	elseif rfind(form, "er$") then
		return rsub(form, "er$", "ère")
	elseif rfind(form, "el$") then
		return form .. "le"
	elseif rfind(form, "et$") then
		return form .. "te"
	elseif rfind(form, "on$") then
		return form .. "ne"
	elseif rfind(form, "ieur$") then
		return form .. "e"
	elseif rfind(form, "teur$") then
		return rsub(form, "teur$", "trice")
	elseif rfind(form, "eu$") then
		return rsub(form, "eu$", "euse")
	elseif rfind(form, "if$") then
		return rsub(form, "if$", "ive")
	elseif rfind(form, "c$") then
		return rsub(form, "c$", "que")
	elseif rfind(form, "eau$") then
		return rsub(form, "eau$", "elle")
	else
		return form .. "e"
	end
end


local function add_suffix(list, suffix, special)
	local newlist = {}
	for _, form in ipairs(list) do
		if suffix == "s" then
			form = make_plural(form, special)
		elseif suffix == "e" then
			form = make_feminine(form, special)
		else
			error("Internal error: Unrecognized suffix '" .. suffix .. "'")
		end
		table.insert(newlist, form)
	end
	return newlist
end


local no_split_apostrophe_words = {
	 = true,
	 = true,
	 = true,
}


-- 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 params = {
		 = {list = true},
		 = {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().text

	local heads = args
	if pos_functions and pos_functions.param1_is_head and args then
		table.insert(heads, 1, args)
	end
	if args.nolinkhead then
		if #heads == 0 then
			heads = {pagename}
		end
	else
		local auto_linked_head = require("Module:romance utilities").add_lemma_links(pagename, args.splithyph,
			no_split_apostrophe_words)
		if #heads == 0 then
			heads = {auto_linked_head}
		else
			for _, head in ipairs(heads) do
				if head == auto_linked_head then
					track("redundant-head")
				end
			end
		end
	end

	local data = {
		lang = lang,
		pos_category = poscat,
		categories = {},
		heads = heads,
		genders = {},
		inflections = {},
		categories = {},
		pagename = pagename
	}

	if pagename:find("^%-") and suffix_categories then
		data.pos_category = "suffixes"
		local singular_poscat = poscat:gsub("s$", "")
		table.insert(data.categories, langname .. " " .. singular_poscat .. "-forming suffixes")
	end

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

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

local allowed_genders = {
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
	 = true,
}

local additional_allowed_pronoun_genders = {
	 = true,
	 = true,
	 = true,
	 = true, -- mf-p doesn't make sense for e.g. ]/]
}

local function get_noun_pos(is_proper)
	return {
		params = {
			 = {},
			 = {list = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			},
		func = function(args, data)
			local lemma = data.pagename
		local pos = is_proper and "tulajdonnevek" or "főnevek"

			-- Gather genders
			table.insert(data.genders, args)
			for _, g in ipairs(args.g) do
				table.insert(data.genders, g)
			end

			local function process_inflection(label, infls, quals)
				infls.label = label
				for i, infl in ipairs(infls) do
					if quals then
						infls = {term = infl, qualifiers = {quals}}
					end
				end
			end

			-- Gather all the plural parameters from the numbered parameters.
			local plurals = args

			-- Add categories for genders
			if #data.genders == 0 then
				table.insert(data.genders, "?")
			end

			local mode = nil

			for _, g in ipairs(data.genders) do
				if g == "m-p" or g == "f-p" or g =="mf-p" or g == "mfbysense-p" then
					mode = "p"
				end

				if g == "?" and (is_proper or mw.title.getCurrentTitle().nsText == "Template") then
					-- allow unknown gender in template example and proper nouns,
					-- since there are currently so many proper nouns with
					-- unspecified gender
				elseif g and g ~= "" and not allowed_genders then
					error("Unrecognized " .. langname .. " gender: " .. g)
				end
			end

			-- Decide how to show the plurals
			mode = mode or plurals

			local function insert_countable_cat()
				table.insert(data.categories, langname .. " megszámlálható " .. pos)
			end
			local function insert_uncountable_cat()
				-- Most proper nouns are uncountable, so don't create a category for them
				if not is_proper then
					table.insert(data.categories, langname .. " megszámlálhatatlan " .. pos)
				end
			end
				
			if mode == "!" then
				-- Plural is not attested
				table.insert(data.inflections, {label = "plural not attested"})
				table.insert(data.categories, langname .. " " .. pos .. " with unattested plurals")
			elseif mode == "p" then
				-- Plural-only noun, doesn't have a plural
				table.insert(data.inflections, {label = "csak tsz."})
				table.insert(data.categories, langname .. " pluralia tantum")
			else
				if mode == "?" then
					-- Plural is unknown
					table.remove(plurals, 1)  -- Remove the mode parameter
				elseif mode == "-" then
					-- Uncountable noun; may occasionally have a plural
					table.remove(plurals, 1)  -- Remove the mode parameter
					insert_uncountable_cat()

					-- If plural forms were given explicitly, then show "usually"
					if #plurals > 0 then
						track("count-uncount")
						table.insert(data.inflections, {label = "usually " .. glossary_link("uncountable")})
						insert_countable_cat()
					else
						table.insert(data.inflections, {label = glossary_link("uncountable")})
					end
				elseif mode == "~" then
					-- Mixed countable/uncountable noun, always has a plural
					table.remove(plurals, 1)  -- Remove the mode parameter
					table.insert(data.inflections, {label = glossary_link("countable") .. " and " .. glossary_link("uncountable")})
					insert_uncountable_cat()
					insert_countable_cat()

					-- If no plural was given, add a default one now
					if #plurals == 0 then
						plurals = {"+"}
					end
				elseif is_proper then
					-- Default proper noun; uncountable unless plural(s) specified
					if #plurals > 0 then
						insert_countable_cat()
					else
						insert_uncountable_cat()
					end
				else
					-- The default, always has a plural
					insert_countable_cat()

					-- If no plural was given, add a default one now
					if #plurals == 0 then
						plurals = {"+"}
					end
				end

				-- Gather plurals, handling requests for default plurals
				for i, pl in ipairs(plurals) do
					if pl == "#" then
						pl = lemma
					elseif pl == "s" or pl == "x" then
						pl = lemma .. pl
					elseif pl == "+" then
						pl = make_plural(lemma)
					elseif pl:find("^%+") then
						pl = require("Module:romance utilities").get_special_indicator(pl)
						pl = make_plural(lemma, pl)
					end

					if not exists(pl) then
						--table.insert(data.categories, langname .. " " .. pos .. " with red links in their headword lines")
					end

					plurals = pl
				end

				process_inflection("plural", plurals, args)
				plurals.accel = {form = "p"}
				plurals.request = true

				-- Add the plural forms; do this in some cases even if no plurals
				-- specified so we get a "please provide plural" message.
				if mode ~= "-" and (not is_proper or mode) or #plurals > 0 then
					table.insert(data.inflections, plurals)
				end
			end

			local function insert_inflection(label, arg, process_arg)
				local forms = args
				if process_arg then
					for i, form in ipairs(forms) do
						forms = process_arg(form)
					end
				end
				process_inflection(label, forms, args)
				if #forms > 0 then
					table.insert(data.inflections, forms)
					check_exists(forms, data.categories, pos)
				end
				return forms
			end

			-- Add the feminine forms
			local fems = insert_inflection("feminine", "f", function(form)
				-- Allow '#', 'e', '+', '+first', etc. for feminine.
				if form == "#" then
					return lemma
				elseif form == "e" then
					return lemma .. form
				elseif form == "+" then
					return make_feminine(lemma)
				elseif form:find("^%+") then
					form = require("Module:romance utilities").get_special_indicator(form)
					return make_feminine(lemma, form)
				else
					return form
				end
			end)
			fems.accel = {form = "f"}

			-- Add the masculine forms
			insert_inflection("masculine", "m")

			-- Add the diminutives
			local dims = insert_inflection("diminutive", "dim")
			dims.accel = {form = "diminutive"}
		end
	}
end

pos_functions = get_noun_pos(false)

pos_functions = get_noun_pos(true)

local function get_pronoun_pos()
	return {
		params = {
			 = {list = true},
			 = {alias_of = "g"},
			 = {list = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			 = {list = true},
			 = {list = true, allow_holes = true},
			},
		func = function(args, data)
			-- Gather genders
			data.genders = args.g

			local function process_inflection(label, infls, quals)
				infls.label = label
				for i, infl in ipairs(infls) do
					if quals then
						infls = {term = infl, qualifiers = {quals}}
					end
				end
			end

			local function insert_inflection()
			end

			-- Validate/canonicalize genders
			for i, g in ipairs(data.genders) do
				if g == "?" and mw.title.getCurrentTitle().nsText == "Template" then
					-- allow unknown gender in template example
				elseif g == "?" then
					-- FIXME, remove this branch once we’ve added the required genders
					track("missing-pron-gender")
				elseif g and not allowed_genders and not additional_allowed_pronoun_genders then
					error("Unrecognized " .. langname .. " gender: " .. g)
				end
			end

		-- Gather all inflections.
		process_inflection("hímnem", args, args)			
		process_inflection("nőnem", args, args)			
		process_inflection("hímnem többesszám", args, args)			
		process_inflection("nőnem többesszám", args, args)			
		process_inflection("többesszám", args, args)			

			-- Add the inflections
			if #args > 0 then
				table.insert(data.inflections, args)
			end
			if #args > 0 then
				table.insert(data.inflections, args)
			end
			if #args > 0 then
				table.insert(data.inflections, args)
			end
			if #args > 0 then
				table.insert(data.inflections, args)
			end
			if #args > 0 then
				table.insert(data.inflections, args)
			end
		end
	}
end

pos_functions = get_pronoun_pos(true)
pos_functions = get_pronoun_pos(true)

local function get_misc_pos()
	return {
		param1_is_head = true,
		params = {
			 = {},
		},
		func = function(args, data)
		end
	}
end

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

pos_functions = get_misc_pos()

local function do_adjective(pos)
	return {
		params = {
			 = {},
			 = {type = "boolean"},
			 = {}, -- special indicator: "first", "first-last", etc.
			 = {},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {list = true},
			 = {type = "boolean"},
			},
		func = function(args, data)
			local lemma = data.pagename
			if args.onlyg == "p" or args.onlyg == "m-p" or args.onlyg == "f-p" then
				table.insert(data.categories, langname .. " pluralia tantum")
			end
			if args.onlyg == "s" or args.onlyg == "f-s" or args.onlyg == "f-s" then
				table.insert(data.categories, langname .. " singularia tantum")
			end
			if args.onlyg then
				table.insert(data.categories, langname .. " defective " .. pos)
			end

			local function process_inflection(label, arg, accel, get_default, explicit_default_only)
				local default_val
				local function default()
					if default_val == nil then
						if get_default then
							default_val = get_default()
						else
							default_val = false
						end
					end
					return default_val
				end
				local orig_infls = #args > 0 and args or explicit_default_only and {} or default() or {}
				local infls = {}
				if #orig_infls > 0 then
					infls.label = label
					infls.accel = accel and {form = accel} or nil
					local quals = args
					for i, infl in ipairs(orig_infls) do
						if infl == "#" then
							infl = lemma
						elseif infl == "e" or infl == "s" or infl == "x" then
							infl = lemma .. infl
						elseif infl == "+" then
							infl = default()
							if not infl then
								error("Can't use '+' with " .. arg .. "=; no default available")
							end
						end
						if type(infl) == "table" then
							for _, inf in ipairs(infl) do
								if quals then
									table.insert(infls, {term = inf, qualifiers = {quals}})
								else
									table.insert(infls, inf)
								end
							end
						elseif quals then
							table.insert(infls, {term = infl, qualifiers = {quals}})
						else
							table.insert(infls, infl)
						end
					end
					table.insert(data.inflections, infls)
				end
				return infls
			end

			if args.sp and not require("Module:romance utilities").allowed_special_indicators then
				local indicators = {}
				for indic, _ in pairs(require("Module:romance utilities").allowed_special_indicators) do
					table.insert(indicators, "'" .. indic .. "'")
				end
				table.sort(indicators)
				error("Special inflection indicator beginning can only be " ..
					require("Module:table").serialCommaJoin(indicators, {dontTag = true}) .. ": " .. args.sp)
			end

			local function get_current()
				return #args.current > 0 and args.current or {data.pagename}
			end

			if args.onlyg == "p" then
				table.insert(data.inflections, {label = "csak többes"})
				if args ~= "mf" then
					-- Handle feminine plurals
					process_inflection("feminine plural", "fp", "f|p")
				end
			elseif args.onlyg == "s" then
				table.insert(data.inflections, {label = "csak egyes"})
				if not (args == "mf" or #args.f == 0 and rfind(data.pagename, "e$")) then
					-- Handle feminines
					process_inflection("feminine plural", "fp", "f|p", function()
						return add_suffix(get_current(), "e", args.sp)
					end)
				end
			elseif args.onlyg == "m" then
				table.insert(data.genders, "m")
				table.insert(data.inflections, {label = "csak hímnem"})
				-- Handle masculine plurals
				process_inflection("masculine plural", "mp", "m|p", function()
					return add_suffix(get_current(), "s", args.sp)
				end)
			elseif args.onlyg == "f" then
				table.insert(data.genders, "f")
				table.insert(data.inflections, {label = "csak nőnem"})
				-- Handle feminine plurals
				process_inflection("feminine plural", "fp", "f|p", function()
					return add_suffix(get_current(), "s", args.sp)
				end)
			elseif args.onlyg then
				table.insert(data.genders, args.onlyg)
				table.insert(data.inflections, {label = "defective"})
			else
				-- Gather genders
				local gender = args
				-- Default to mf if base form ends in -e and no feminine,
				-- feminine plural or gender specified
				if not gender and #args.f == 0 and #args.fp == 0 and rfind(data.pagename, "e$")
					and not rfind(data.pagename, " ") then
					gender = "mf"
				end

				if #args.current > 0 then
					track("adj-current")
				end

				if args.intr then
					table.insert(data.inflections, {label = glossary_link("intransitive")})
					table.insert(data.inflections, {label = "hence " .. glossary_link("invariable")})
					args.inv = true
				elseif args.inv then
					table.insert(data.inflections, {label = glossary_link("nem ragozható")})
				end

				-- Handle plurals of mf adjectives
				if not args.inv and gender == "mf" then
					process_inflection("plural", "p", "p", function()
						return add_suffix(get_current(), "s", args.sp)
					end)
				end

				if not args.inv and gender ~= "mf" then
					-- Handle masculine form if not same as lemma; e.g. ] with m=+, m2=sûr de lui
					process_inflection("hímnem esz.", "m", "m|s",
						function() return {data.pagename} end, "explicit default only")

					-- Handle case of special masculine singular before vowel
					process_inflection("masculine singular before vowel", "mv", "m|s")

					-- Handle feminines
					local feminines = process_inflection("nőnem", "f", "f|s", function()
						return add_suffix(get_current(), "e", args.sp)
					end)

					-- Handle masculine plurals
					process_inflection("hímnem tsz.", "mp", "m|p", function()
						return add_suffix(get_current(), "s", args.sp)
					end)

					-- Handle feminine plurals
					process_inflection("nőnem tsz.", "fp", "f|p", function()
						return add_suffix(feminines, "s", args.sp)
					end)
				end
			end

			-- Handle comparatives
			process_inflection("comparative", "comp", "comparative")

			-- Handle superlatives
			process_inflection("superlative", "sup", "superlative")

			-- Check existence
			for _, infls in pairs(data.inflections) do
				if not check_exists(infls, data.categories, pos) then
					break
				end
			end
		end
	}
end

pos_functions = do_adjective("melléknevek")
pos_functions = do_adjective("befejezett alakok")

pos_functions = {
	param1_is_head = true,
	params = {
		 = {},
		 = {list = true},
	},
	func = function(args, data)
		local pos = "igék"
		for _, ty in ipairs(args.type) do
			local category, label
			if ty == "auxiliary" then
				category = "auxiliary"
			elseif ty == "defective" then
				category = "defective"
				label = glossary_link("defective")
			elseif ty == "impersonal" then
				category = "impersonal"
				label = glossary_link("impersonal")
			elseif ty == "modal" then
				category = "modal"
			elseif ty == "reflexive" then
				category = "reflexive"
			elseif ty == "transitive" then
				label = glossary_link("transitive")
				category = "transitive"
			elseif ty == "intransitive" then
				label = glossary_link("intransitive")
				category = "intransitive"
			elseif ty == "ambitransitive" or ty == "ambi" then
				category = {"transitive", "intransitive"}
				label = glossary_link("transitive") .. " and " .. glossary_link("intransitive")
			end
			if category then
				if type(category) == "table" then
					for _, cat in ipairs(category) do
						table.insert(data.categories, langname .. " " .. cat .. " " .. pos)
					end
				else
					table.insert(data.categories, langname .. " " .. category .. " " .. pos)
				end
			end
			if label then
				table.insert(data.inflections, {label = label})
			end
		end
	end
}

return export