Модуль:inflection adj pl

Документация

Модуль автоматического склонения польских прилагательных. Использует шаблон {{падежи pl 2}} для вывода таблицы словоизменения.

Функции

Вывод таблицы склонения

{{#invoke:inflection adj pl|template_decl_auto|<лемма>}}

Параметры

  1. неименованный — лемма
  2. anim : yes/no — флаг для одушевленных и неодушевленных
local export = {}

-- automatic declension

local inflectors = {}

inflectors["^((.+)([kg]))[ia]e?$"] = function (pargs, base, base1, extra)
	local ending = { ["k"] = "cy"; ["g"] = "dzy"; }
	return {
		base .. "i",
		base .. "a",
		base .. "ie",
		base1 .. ending[extra],
		base .. "ie",
		base .. "iego",
		base .. "iej",
		base .. "ich",
		base .. "iemu",
		base .. "im",
		base .. "ą",
		base .. "im",
		base .. "imi",
		(pargs.olddat and (base .. "u") or nil)
	}
end

inflectors["^((.+)[npbfwsz]i)[ae]?$"] = function (pargs, base, base1)
	return {
		base,
		base .. "a",
		base .. "e",
		base,
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ch",
		base .. "emu",
		base .. "m",
		base .. "ą",
		base .. "m",
		base .. "mi"
	}
end

inflectors["^((.+)l)[iae]$"] = function (pargs, base, base1)
	return {
		base .. "i",
		base .. "a",
		base .. "e",
		base .. "i",
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ich",
		base .. "emu",
		base .. "im",
		base .. "ą",
		base .. "im",
		base .. "imi"
	}
end

inflectors["^(.+c)i[ae]?$"] = function (pargs, base, base1)
	return {
		base .. "i",
		base .. "ia",
		base .. "ie",
		base .. "i",
		base .. "ie",
		base .. "iego",
		base .. "iej",
		base .. "ich",
		base .. "iemu",
		base .. "im",
		base .. "ią",
		base .. "im",
		base .. "imi"
	}
end

inflectors["^((.+)([os])n)[yae]$"] = function (pargs, base, base1, extra)
	local mpl_suffix

	if base:match("zielon$") or base:match("czerwon$") or base:match("słon$") then
		-- probably the only exceptions
		mpl_suffix = "oni"
	else
		mpl_suffix = ({ ["o"] = "eni", ["s"] = "śni", ["z"] = "źni" })[extra]
	end

	return {
		base .. "y",
		base .. "a",
		base .. "e",
		base1 .. mpl_suffix,
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ych",
		base .. "emu",
		base .. "ym",
		base .. "ą",
		base .. "ym",
		base .. "ymi",
	}
end
inflectors["^((.+[^crs])(z)n)[yae]$"] = inflectors["^((.+)([os])n)[yae]$"]

inflectors["^(.+[^osz]n)[yae]$"] = function (pargs, base, base1, extra)
	return {
		base .. "y",
		base .. "a",
		base .. "e",
		base .. "i",
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ych",
		base .. "emu",
		base .. "ym",
		base .. "ą",
		base .. "ym",
		base .. "ymi"
	}
end
inflectors["^(.+[crs]zn)[yae]$"] = inflectors["^(.+[^osz]n)[yae]$"]

inflectors["^(.+[wmpb])[yae]$"] = function (pargs, base, base1)
	return {
		base .. "y",
		base .. "a",
		base .. "e",
		base .. "i",
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ych",
		base .. "emu",
		base .. "ym",
		base .. "ą",
		base .. "ym",
		base .. "ymi"
	}
end

inflectors["^((.+s)z?)[yae]$"] = function (pargs, base, base1)
	return {
		base .. "y",
		base .. "a",
		base .. "e",
		base1 .. "i",
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ych",
		base .. "emu",
		base .. "ym",
		base .. "ą",
		base .. "ym",
		base .. "ymi"
	}
end

inflectors["^(.+[^fwtdmrłnizshpb])[yae]$"] = function (pargs, base, base1)
	return {
		base .. "y",
		base .. "a",
		base .. "e",
		base .. "y",
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ych",
		base .. "emu",
		base .. "ym",
		base .. "ą",
		base .. "ym",
		base .. "ymi"
	}
end
inflectors["^(.+[cdr]z)[yae]$"] = inflectors["^(.+[^fwtdmrłnizshpb])[yae]$"]

inflectors["^((.+)([dr]))[yae]$"] = function (pargs, base, base1, extra)
	local soft_mpl_cons = { ["ch"] = "si", ["h"] = "si", ["zł"] = "źli", ["sł"] = "śli", ["ł"] = "li", ["r"] = "rzy", ["t"] = "ci", ["st"] = "ści", ["d"] = "dzi" }
	
	return {
		base .. "y",
		base .. "a",
		base .. "e",
		base1 .. soft_mpl_cons[extra],
		base .. "e",
		base .. "ego",
		base .. "ej",
		base .. "ych",
		base .. "emu",
		base .. "ym",
		base .. "ą",
		base .. "ym",
		base .. "ymi",
		(pargs.olddat and (base .. "u") or nil)
	}
end
inflectors["^((.-)(c?h))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]
inflectors["^((.*[^s])(zł))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]
inflectors["^((.*)(sł))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]
inflectors["^((.*[^sz])(ł))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]
inflectors["^((.*sz)(ł))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]
inflectors["^((.*)(st))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]
inflectors["^((.*[^s])(t))[yae]$"] = inflectors["^((.+)([dr]))[yae]$"]

-- archaic forms
inflectors["^(.+[^i])en$"] = function (pargs, base, base1, extra)
	return {
		base .. "en",
		base .. "na",
		base .. "ne",
		base .. "ni",
		base .. "ne",
		base .. "nego",
		base .. "nej",
		base .. "nych",
		base .. "nemu",
		base .. "nym",
		base .. "ną",
		base .. "nym",
		base .. "nymi"
	}
end

inflectors["^(.+)on$"] = function (pargs, base, base1, extra)
	return {
		base .. "on",
		base .. "ona",
		base .. "one",
		base .. "eni",
		base .. "one",
		base .. "onego",
		base .. "onej",
		base .. "onych",
		base .. "onemu",
		base .. "onym",
		base .. "oną",
		base .. "onym",
		base .. "onymi"
	}
end

-- jakikolwiek, którykolwiek
inflectors["^(.+)kolwiek$"] = function (pargs, base)
	local result = export.autoinflect(base, pargs)
	if result then
		for i, item in ipairs(result) do
			result[i] = item .. "kolwiek"	
		end
		return result	
	end
end

function export.autoinflect(lemma, pargs)
	pargs = pargs or {}
	for pat, inflector in pairs(inflectors) do
		local st, en, stem, substem, extra = mw.ustring.find(lemma, pat)
		if st then
			return inflector(pargs, stem, substem, extra)
		end
	end
end


function export.template_decl_auto(frame)
	local title = mw.title.getCurrentTitle()
	local pargs = frame:getParent().args
	local lemma = frame.args[1] or pargs[1]; 
	
	if lemma == "" then lemma = nil end
	lemma = lemma or (title.namespace == 0 and title.text)
	
	local params;
	
	if title.fullText == frame:getParent():getTitle() then
		params = {
			"[[-ski]], [[-ty]]",
			"[[-ska]], [[-ta]]",
			"[[-skie]], [[-te]]",
			"[[-scy]], [[-ci]]",
			"[[-skie]], [[-te]]",
			"[[-skiego]], [[-tego]]",
			"[[-skiej]], [[-tej]]",
			"[[-skich]], [[-tych]]",
			"[[-skiemu]], [[-temu]]",
			"[[-skim]], [[-tym]]",
			"[[-ską]], [[-tą]]",
			"[[-skim]], [[-tym]]",
			"[[-skimi]], [[-tymi]]",
			"[[-sku]], [[-tu]]"
		}
	else
		params = export.autoinflect(lemma, pargs);
		if params == nil then
			return error(("No declension pattern matches '%s'"):format(lemma))
		end
	end
	local anum = pargs['anim'] or '';
	if anum ~= '' then
	   params['anim'] = anum;
	end
	return frame:expandTemplate{ title = "Шаблон:падежи pl 2", args = params }
end

return export