Module:pl-headword

Ut Wikiwurdboek
De neikommende dokumintaasje stiet op Module:pl-headword/dokumintaasje. [bewurkje]

Oernommen fan en:Module:pl-headword.

Oerset:

  • (parten fan) kategorynammen
  • lebels

Oanpast:

  • parameters skowe 1 plak op
  • accel útskeakele

local export = {}

local lang = require("Module:languages").getByCode("pl")

local function collect_numbered(args, prefix, target)
	local was_empty = false
	if args[prefix] then
		table.insert(target, args[prefix])
		local i = 2
		while args[prefix .. i] do
			table.insert(target, args[prefix .. i])
			i = i + 1
		end
	end
	
	return target
end

local function add_if_nonempty(infls, item)
	if #item > 0 then
		table.insert(infls, item)	
	end
end

-- verbs

-- Aspect normalization table.
-- Note that determinate, indeterminate and frequentative aspects mainly make
-- sense for verbs of motion. Most verbs will have either perfective or
-- imperfective aspect.
local norm_aspect = {
	-- perfective aspect: zrobić, dojechać, pójść
	["p"]            = "pf",
	["pf"]           = "pf",
	["perf"]         = "pf",
	["perfective"]   = "pf",
	-- imperfective aspect: robić, karać
	["i"]            = "impf",
	["impf"]         = "impf",
	["imperf"]       = "impf",
	["imperfective"] = "impf",
	-- determinate aspect: jechać, iść
	-- implies imperfective
	["impf-det"]     = "impf-det",
	["det"]          = "impf-det",
	-- indeterminate aspect: jeździć, chodzić
	-- implies imperfective
	["impf-indet"]   = "impf-indet",
	["indet"]        = "impf-indet",
	-- frequentative aspect: chadzać
	-- implies imperfective and indeterminate
	["freq"]         = "impf-freq",
	["if"]           = "impf-freq",
	["impf-freq"]    = "impf-freq",
}

function export.show_verb(frame)
	local args = frame:getParent().args
	
	local data = {lang = lang, pos_category = "Tiidwurden", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
	local tracking_categories = {}
	local aspect = norm_aspect[args.aspect or args.asp or args.a or false] or "?"

	if aspect == "pf" then
		table.insert(data.genders, "pf")
		table.insert(data.categories, "Perfektive tiidwurden yn it Poalsk")
	elseif (aspect == "impf") or (aspect == "impf-det") or (aspect == "impf-indet") or (aspect == "impf-freq") then
		table.insert(data.genders, "impf")
		table.insert(data.categories, "Ymperfektive tiidwurden yn it Poalsk")
	else
		table.insert(data.genders, "?")
		table.insert(data.categories, "Tiidwurden mei ûntbrekkend aspekt yn it Poalsk")
	end

	if aspect == "impf-det" then
		table.insert(data.inflections, {label = "folslein"})
		table.insert(data.categories, "Folsleine tiidwurden yn it Poalsk")
	elseif aspect == "impf-indet" then
		table.insert(data.inflections, {label = "ûnfolslein"})
		table.insert(data.categories, "Unfolsleine tiidwurden yn it Poalsk")
	elseif aspect == "impf-freq" then
		table.insert(data.inflections, {label = "ûnfolslein"})
		table.insert(data.inflections, {label = "frekwintatyf"})
		table.insert(data.categories, "Unfolsleine tiidwurden yn it Poalsk")
		table.insert(data.categories, "Frekwintative tiidwurden yn it Poalsk")
	end

	local perf = { label = "perfektyf" }
	local imperf = { label = "ymperfektyf" }
	local det = { label = "ymperfektyf folslein" }
	local indet = { label = "ûnfolslein" }
	local freq = { label = "frekwintatyf" }
	
	-- legacy parameter
	if args[2] then
		table.insert(tracking_categories, "-pl- verbum mei posisjonele parameters")
		if (aspect == "impf") then
			table.insert(perf, args[2])
		elseif (aspect == "pf") then
			table.insert(imperf, args[2])
		end
	end

	collect_numbered(args, "perf", perf)
	collect_numbered(args, "pf", perf)
	collect_numbered(args, "imperf", imperf)
	collect_numbered(args, "impf", imperf)
	collect_numbered(args, "det", det)
	collect_numbered(args, "indet", indet)
	collect_numbered(args, "freq", freq)
	
	-- "pref" would never come before "det" (pf; det-inedt, impf; det-indet, indet; det-pf, etc.)
	add_if_nonempty(data.inflections, det)
	add_if_nonempty(data.inflections, perf)
	add_if_nonempty(data.inflections, imperf)
	add_if_nonempty(data.inflections, indet)
	add_if_nonempty(data.inflections, freq)

	return require("Module:headword").full_headword(data) ..
		require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end

function export.show_participle(frame)
	local args = frame:getParent().args
	
	local data = {lang = lang, pos_category = "Mulwurden", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
	local tracking_categories = {}
	local aspect = norm_aspect[args.aspect or args.asp or args.a or false] or "?"
	
	-- type of participle
	local ptype = args[2]
	if not ptype then
		local PAGENAME = mw.title.getCurrentTitle().fullText
		
		if PAGENAME:match("ąc[yae]$") then -- biegnący, 
			ptype = "aadj"			
		elseif PAGENAME:match("[nt][yae]$") then -- otwarty, uwielbiany
			ptype = "padj"
		elseif PAGENAME:match("ąc$") then
			ptype = "cadv"
		elseif PAGENAME:match("szy$") then
			ptype = "aadv"
		end
	end

	if ptype then
		if ptype == "pasv-adj" or ptype == "padj" then
			table.insert(data.categories, "Passive eigenskiplike mulwurden yn it Poalsk")
		elseif ptype == "actv-adj" or ptype == "aadj" then
			table.insert(data.categories, "Aktive eigenskiplike mulwurden yn it Poalsk")
		elseif ptype == "antr-adv" or ptype == "aadv" then
			table.insert(data.categories, "Anterieure bywurdlike mulwurden yn it Poalsk")
		elseif ptype == "cont-adv" or ptype == "cadv" then
			table.insert(data.categories, "Lyktidige bywurdlike mulwurden yn it Poalsk")
		else
			table.insert(tracking_categories, "-pl- mulwd mei net-werkend type")
		end
	else
		table.insert(tracking_categories, "-pl- mulwd sûnder type")
	end

	if (aspect == "pf") or (aspect == "pf-it") or (aspect == "pf-sem") then
		table.insert(data.genders, "pf")
	elseif (aspect == "impf") or (aspect == "impf-it") or (aspect == "impf-dur") then
		table.insert(data.genders, "impf")
	end

	if aspect == "impf-dur" then
		table.insert(data.inflections, {label = "duratyf"})
	elseif aspect == "impf-it" then
		table.insert(data.inflections, {label = "iteratyf"})
	elseif aspect == "pf-sem" then
		table.insert(data.inflections, {label = "semelfaktyf"})
	elseif aspect == "pf-it" then
		table.insert(data.inflections, {label = "iteratyf"})
	end

	return require("Module:headword").full_headword(data) ..
		require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end

-- nouns and proper nouns

local noun_gender_cat = {
	["m"     ] = "Manlike haadwurden yn it Poalsk",
	["m-an"  ] = "Manlike haadwurden yn it Poalsk",
	["m-in"  ] = "Manlike haadwurden yn it Poalsk",
	["m-pr"  ] = "Manlike haadwurden yn it Poalsk",
	["f"     ] = "Froulike haadwurden yn it Poalsk",
	["n"     ] = "Unsidige haadwurden yn it Poalsk",
	["m-p"   ] = false,
	["m-pr-p"] = false,
	["m-an-p"] = false,
	["m-in-p"] = false,
	["f-p"   ] = false,
	["n-p"   ] = false,
	["p"     ] = false,
}

function export.show_noun(frame)
	local args = frame:getParent().args
	
	local data = {lang = lang, pos_category = frame.args.proper and "Nammen" or "Haadwurden", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
	local tracking_categories = {}
	
	if args.indecl and args.indecl ~= '' then
		table.insert(data.inflections, { label = "net bûchber" })
		table.insert(data.categories, "Net-bûchbere haadwurden yn it Poalsk")
	end

	add_if_nonempty(data.inflections, collect_numbered(args, "abbr", { label = "ôfkoarting" }))
	add_if_nonempty(data.inflections, collect_numbered(args, "dim", { label = "ferlytsingswurd" }))
	add_if_nonempty(data.inflections, collect_numbered(args, "aug", { label = "fergruttingswurd" }))
	add_if_nonempty(data.inflections, collect_numbered(args, "f", { label = "froulik" }))
	add_if_nonempty(data.inflections, collect_numbered(args, "m", { label = "manlik" }))

	local g, genders = args.g or args[2]
	if g then
		if noun_gender_cat[g] ~= nil then
			data.genders = { g }
			table.insert(data.categories, noun_gender_cat[g] or nil)
			if g == "m" then
				table.insert(tracking_categories, "Manlike haadwurden sûnder besielens yn it Poalsk")
			end
		else
			data.genders = { "?" }
		end
	else
		data.genders = { "?" }
	end

	return require("Module:headword").full_headword(data) ..
		require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end

-- adjectives and adverbs

function export.show_adj_adv(frame)
	local args = frame:getParent().args
	
	local data = {lang = lang, categories = {}, sort_key = args.sort, heads = {args.head}, inflections = {}}
	local tracking_categories = {}
	
	local PAGENAME = mw.title.getCurrentTitle().text
	
	if frame.args.adverb then
		data.pos_category = "Bywurden"
	else
		data.pos_category = "Eigenskipswurden"
	end
	
	local comparative, superlative = {}, {}
	
	local i = 2
	
	if args[2] == "-" then
		if frame.args.adverb then
			table.insert(data.categories, "Bywurden sûnder graadbûging yn it Poalsk")
		else
			table.insert(data.categories, "Eigenskipswurden sûnder graadbûging yn it Poalsk")
		end

		if not args[3] then
			table.insert(data.inflections, { label = "gjin graadbûging" })
		else
			table.insert(data.inflections, { label = "soms gjin graadbûging" })
			i = i + 1
			while args[i] do
				local comp, super
				if frame.args.adverb and ((args[i] == "j") or (args[i] == "regular")) then
					table.insert(comparative, PAGENAME .. "j")
					table.insert(superlative, "naj" .. PAGENAME .. "j")
				elseif args[i] == "bardziej" then
					table.insert(comparative, "[[bardziej]] " .. PAGENAME)
					table.insert(superlative, "[[najbardziej]] " .. PAGENAME)
				elseif args[i] then
					table.insert(comparative, args[i])
					table.insert(superlative, "naj" .. args[i])
				end
				i = i + 1
			end

			-- 'accel' n.f.t. (sjoch https://en.wiktionary.org/w/index.php?title=Wiktionary:ACCEL) - PiefPafPier
			-- comparative.label, comparative.accel = "comparative", {form = "comparative"}
			comparative.label = "meartrime"
			-- superlative.label, superlative.accel = "superlative", {form = "superlative"}
			superlative.label = "measttrime"

			table.insert(data.inflections, comparative)
			table.insert(data.inflections, superlative)
		end
	elseif args[2] then
		while args[i] do
			local comp, super
			if frame.args.adverb and ((args[i] == "j") or (args[i] == "regular")) then
				table.insert(comparative, PAGENAME .. "j")
				table.insert(superlative, "naj" .. PAGENAME .. "j")
			elseif args[i] == "bardziej" then
				table.insert(comparative, "[[bardziej]] " .. PAGENAME)
				table.insert(superlative, "[[najbardziej]] " .. PAGENAME)
			elseif args[i] then
				table.insert(comparative, args[i])
				table.insert(superlative, "naj" .. args[i])
			end
			i = i + 1
		end

		-- comparative.label, comparative.accel = "comparative", {form = "comparative"}
		comparative.label = "meartrime"
		-- superlative.label, superlative.accel = "superlative", {form = "superlative"}
		superlative.label = "measttrime"
		
		table.insert(data.inflections, comparative)
		table.insert(data.inflections, superlative)
	else
		table.insert(tracking_categories, "-pl- adjek as adverb sûnder meartrime")
	end

	if not frame.args.adverb then
		if args.adv then
			if args.adv ~= '-' then
				add_if_nonempty(data.inflections, collect_numbered(args, "adv", { label = "bywurd" }))
			end
		else
			table.insert(tracking_categories, "-pl- adjek sûnder byhearrend bywurd")
		end
	end

	add_if_nonempty(data.inflections, collect_numbered(args, "abbr", { label = "ôfkoarting" }))

	return require("Module:headword").full_headword(data) ..
		require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end

return export