본문으로 이동

모듈:ru-verb

위키낱말사전, 말과 글의 누리

관련 모듈

[편집]

--[=[
--	This module contains functions for creating inflection tables for Russian
--	verbs.
--]=]

-- local m_utilities = require("Module:utilities")
-- local com = require("Module:ru-common")

local export = {}

-- Within this module, conjugations are the functions that do the actual
-- conjugating by creating the forms of a basic verb.
-- They are defined further down.
local conjugations = {}

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

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	local conj_type = frame.args[1] or error("Conjugation type has not been specified. Please pass parameter 1 to the module invocation")
	local args = frame:getParent().args
	PAGENAME = mw.title.getCurrentTitle().text
	NAMESPACE = mw.title.getCurrentTitle().nsText

	-- Verb type, one of impf, pf, impf-intr, pf-intr, impf-refl, pf-refl.
	-- Default to impf on the template page so that there is no script error.
	local verb_type = args[1] or (NAMESPACE == "Template" and "impf") or error("Verb type (first parameter) has not been provided")
	-- verbs may have reflexive ending stressed in the masculine singular: занялся́, начался́, etc.
	local reflex_stress = args["reflex_stress"] -- "ся́"

	local forms, title, categories

	if conjugations[conj_type] then
		forms, title, categories = conjugations[conj_type](args)
	else
		error("Unknown conjugation type '" .. conj_type .. "'")
	end

	-- This form is not always present on verbs, so it needs to be specified explicitly.
	forms["past_pasv_part"] = args["past_pasv_part"] or ""

	--alternative forms
	forms["impr_sg2"] = forms["impr_sg2"] or args["impr_sg2"]
	forms["impr_pl2"] = forms["impr_pl2"] or args["impr_pl2"]
	forms["pres_actv_part2"] = forms["pres_actv_part2"] or args["pres_actv_part2"]
	forms["past_actv_part2"] = forms["past_actv_part2"] or args["past_actv_part2"]
	forms["pres_pasv_part2"] = forms["pres_pasv_part2"] or args["pres_pasv_part2"]
	forms["past_pasv_part2"] = forms["past_pasv_part2"] or args["past_pasv_part2"]
	forms["pres_adv_part2"] = forms["pres_adv_part2"] or args["pres_adv_part2"]
	forms["past_adv_part2"] = forms["past_adv_part2"] or args["past_adv_part2"]
	forms["past_adv_part_short2"] = forms["past_adv_part_short2"] or args["past_adv_part_short2"]
	forms["past_m2"] = forms["past_m2"] or args["past_m2"]
	forms["past_m3"] = forms["past_m3"] or args["past_m3"]
	forms["past_f2"] = forms["past_f2"] or args["past_f2"]
	forms["past_n2"] = forms["past_n2"] or args["past_n2"]
	forms["past_pl2"] = forms["past_pl2"] or args["past_pl2"]
	forms["pres_futr_1sg2"] = forms["pres_futr_1sg2"] or args["pres_futr_1sg2"]
	forms["pres_futr_2sg2"] = forms["pres_futr_2sg2"] or args["pres_futr_2sg2"]
	forms["pres_futr_3sg2"] = forms["pres_futr_3sg2"] or args["pres_futr_3sg2"]
	forms["pres_futr_1pl2"] = forms["pres_futr_1pl2"] or args["pres_futr_1pl2"]
	forms["pres_futr_2pl2"] = forms["pres_futr_2pl2"] or args["pres_futr_2pl2"]
	forms["pres_futr_3pl2"] = forms["pres_futr_3pl2"] or args["pres_futr_3pl2"]

	local intr = (verb_type == "impf-intr" or verb_type == "pf-intr" or verb_type == "pf-impers" or verb_type == "impf-impers" or verb_type == "pf-impers-refl" or verb_type == "impf-impers-refl")
	local refl = (verb_type == "impf-refl" or verb_type == "pf-refl" or verb_type == "pf-impers-refl" or verb_type == "impf-impers-refl")
	local perf = (verb_type == "pf" or verb_type == "pf-intr" or verb_type == "pf-refl" or verb_type == "pf-impers" or verb_type == "pf-impers-refl")
	--impersonal
	local impers = (verb_type == "pf-impers" or verb_type == "impf-impers" or verb_type == "pf-impers-refl" or verb_type == "impf-impers-refl")

	-- Perfective/imperfective
	if perf then
		table.insert(categories, "Russian perfective verbs")
	else
		table.insert(categories, "Russian imperfective verbs")
	end

	-- call alternative reflexive form to add a stressed "ся́" particle
	if reflex_stress then
		make_reflexive_alt(forms)
	end

	-- Reflexive/intransitive/transitive
	if refl then
		make_reflexive(forms)
		table.insert(categories, "Russian reflexive verbs")
	elseif intr then
		table.insert(categories, "Russian intransitive verbs")
	else
		table.insert(categories, "Russian transitive verbs")
	end

	-- Impersonal
	if impers then
		table.insert(categories, "Russian impersonal verbs")
	end

	-- return make_table(forms, title, perf, intr or refl, impers) .. m_utilities.format_categories(categories, lang)
	return ''
end

--[=[
	Conjugation functions
]=]--

conjugations["1a"] = function(args)
	local forms = {}
	local categories = {"Russian class 1 verbs"}
	local title = "class 1"

	local stem = args[2] or (NAMESPACE == "Template" and "-") or error("Second parameter has not been provided")

	forms["infinitive"] = stem .. "ть"

	forms["pres_actv_part"] = stem .. "ющий"
	forms["past_actv_part"] = stem .. "вший"
	forms["pres_pasv_part"] = stem .. "емый"
	forms["pres_adv_part"] = stem .. "я"
	forms["past_adv_part"] = stem .. "вши"; forms["past_adv_part_short"] = stem .. "в"

	present_je_a(forms, stem)

	forms["impr_sg"] = stem .. "й"
	forms["impr_pl"] = stem .. "йте"

	forms["past_m"] = stem .. "л"
	forms["past_f"] = stem .. "ла"
	forms["past_n"] = stem .. "ло"
	forms["past_pl"] = stem .. "ли"

	return forms, title, categories
end

return export