Modul:sh-ige

A Wikiszótárból, a nyitott szótárból

A modult a Modul:sh-ige/doc lapon tudod dokumentálni

local export = {}

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

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 = "igék", 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, "szerbhorvát befejezett igék")
	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, "szerbhorvát folyamatos igék")
	else
		table.insert(data.genders, "?")
		--table.insert(data.categories, "Polish verbs missing aspect")
	end

	if aspect == "impf-det" then
		table.insert(data.inflections, {label = "determinate"})
		--table.insert(data.categories, "Polish determinate verbs")
	elseif aspect == "impf-indet" then
		table.insert(data.inflections, {label = "indeterminate"})
		--table.insert(data.categories, "Polish indeterminate verbs")
	elseif aspect == "impf-freq" then
		table.insert(data.inflections, {label = "indeterminate"})
		table.insert(data.inflections, {label = "frequentative"})
		--table.insert(data.categories, "Polish indeterminate verbs")
		--table.insert(data.categories, "Polish frequentative verbs")
	end

	local perf = { label = "befejezett" }
	local imperf = { label = "folyamatos" }
	local det = { label = "imperfective determinate" }
	local indet = { label = "indeterminate" }
	local freq = { label = "frequentative" }
	
	-- legacy parameter
	if args[1] then
		--table.insert(tracking_categories, "pl-verb with positional parameters")
		if (aspect == "impf") then
			table.insert(perf, args[1])
		elseif (aspect == "pf") then
			table.insert(imperf, args[1])
		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 = "participles", 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[1]
	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, "Polish passive adjectival participles")
		elseif ptype == "actv-adj" or ptype == "aadj" then
			--table.insert(data.categories, "Polish active adjectival participles")
		elseif ptype == "antr-adv" or ptype == "aadv" then
			--table.insert(data.categories, "Polish anterior adverbial participles")
		elseif ptype == "cont-adv" or ptype == "cadv" then
			--table.insert(data.categories, "Polish contemporary adverbial participles")
		else
			table.insert(tracking_categories, "pl-participle with unrecognized type")
		end
	else
		table.insert(tracking_categories, "pl-participle without 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 = "durative"})
	elseif aspect == "impf-it" then
		table.insert(data.inflections, {label = "iterative"})
	elseif aspect == "pf-sem" then
		table.insert(data.inflections, {label = "semelfactive"})
	elseif aspect == "pf-it" then
		table.insert(data.inflections, {label = "iterative"})
	end

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

 
return export