Dokumentationen för denna modul kan skapas på Modul:ru-verb/dok /test


Modul:ru-verb/dok

local gt = require("Modul:grammar-table")
local export = require("Modul:grammar")

local lang_code_param                          = "ru"
local part_of_speech_param                     = "verb"
local imperfective_templatename                = "ru-verb-impf"
local perfective_templatename                  = "ru-verb-pf"
local imperfective_and_perfective_templatename = "ru-verb-impfpf"

function export._getAcceptedParameters()
	return {}
end

function export._getForms(pagename, templatename, args, meta, format)

	local forms = {}
	
	if meta.aspect == "impf" or meta.aspect == "impfpf" then
		forms.pres_sing_1_pers    = args[1] or "?"
		forms.pres_sing_2_pers    = args[2] or "?"
		forms.pres_sing_3_pers    = args[3] or "?"
		forms.pres_plur_1_pers    = args[4] or "?"
		forms.pres_plur_2_pers    = args[5] or "?"
		forms.pres_plur_3_pers    = args[6] or "?"
		forms.x_pres_part_active  = args[13] or "?"
		forms.x_pres_part_passive = args[14] or "?"
		forms.x_pres_gerund       = args[15] or "?"
		forms.x_pret_part_active  = args[16] or "?"
		forms.x_pret_part_passive = args[17] or "?"
		forms.x_pret_gerund       = args[18] or "?"
	end
	
	if meta.aspect == "pf" or meta.aspect == "impfpf" then
		forms.fut_sing_1_pers  = args[1] or "?"
		forms.fut_sing_2_pers  = args[2] or "?"
		forms.fut_sing_3_pers  = args[3] or "?"
		forms.fut_plur_1_pers  = args[4] or "?"
		forms.fut_plur_2_pers  = args[5] or "?"
		forms.fut_plur_3_pers  = args[6] or "?"
	end
	
	if meta.aspect == "pf" then
		forms.x_pret_part_active  = args[13] or "?"
		forms.x_pret_part_passive = args[14] or "?"
		forms.x_pret_gerund       = args[15] or "?"
	end

	forms.pret_sing_mask    = args[7] or "?"
	forms.pret_sing_neutr   = args[8] or "?"
	forms.pret_sing_fem     = args[9] or "?"
	forms.pret_plur         = args[10] or "?"
	forms.imp_sing          = args[11] or "?"
	forms.imp_plur          = args[12] or "?"

	return forms
end

function export._getMeta(pagename, templatename, args)
	local is_imperfective     = templatename == imperfective_templatename or templatename == imperfective_and_perfective_templatename
	local is_perfective       = templatename == perfective_templatename or templatename == imperfective_and_perfective_templatename
	local aspect              = ""
	local numbered_cells      = 0
	local basic_form_is_given = args['grundform']; 

	if is_imperfective and is_perfective then
		aspect = "impfpf"
		numbered_cells = 18
	elseif is_imperfective then
		aspect = "impf"
		numbered_cells = 18
	elseif is_perfective then
		aspect = "pf"
		numbered_cells = 15
	end

	local meta = {}
	meta.numbered_cells      = numbered_cells
	meta.named_cells         = {}
	meta.aspect              = aspect
	meta.basic_form_is_given = basic_form_is_given

	return meta
end

function export._getWikitable(forms, meta)
	local contains_a_quality_notice  = not not meta.quality_notice
	local note                       = meta.note
	local as_first_part              = meta.as_first_part
	local number_of_columns          = 4
	local aspect                     = meta.aspect
	local aspect_cell                = {}
    local present_or_future_cell     = {}
	local table_section_divider      = '|-\n!colspan="4" style="background:#BFB76D; padding:1px;"|\n|-\n' --should be somewhere else

	local pres_or_fut_sing_1_pers = ""
	local pres_or_fut_sing_2_pers = ""
	local pres_or_fut_sing_3_pers = ""
	local pres_or_fut_plur_1_pers = ""
	local pres_or_fut_plur_2_pers = ""
	local pres_or_fut_plur_3_pers = ""

	if aspect == "impf" then
		aspect_cell = {'!class="main" colspan="2"', "imperfektiv"}
		present_or_future_cell = {'!rowspan="3"', "Presens"}
		pres_or_fut_sing_1_pers = forms.pres_sing_1_pers
		pres_or_fut_sing_2_pers = forms.pres_sing_2_pers
		pres_or_fut_sing_3_pers = forms.pres_sing_3_pers
		pres_or_fut_plur_1_pers = forms.pres_plur_1_pers
		pres_or_fut_plur_2_pers = forms.pres_plur_2_pers
		pres_or_fut_plur_3_pers = forms.pres_plur_3_pers
	elseif aspect == "pf" then
		aspect_cell = {'!class="main" colspan="2"', "perfektiv"}
		present_or_future_cell = {'!rowspan="3"', "Futurum"}
		pres_or_fut_sing_1_pers = forms.fut_sing_1_pers
		pres_or_fut_sing_2_pers = forms.fut_sing_2_pers
		pres_or_fut_sing_3_pers = forms.fut_sing_3_pers
		pres_or_fut_plur_1_pers = forms.fut_plur_1_pers
		pres_or_fut_plur_2_pers = forms.fut_plur_2_pers
		pres_or_fut_plur_3_pers = forms.fut_plur_3_pers
	elseif aspect == "impfpf" then
		aspect_cell = {'!class="main" colspan="2"', "imperfektiv och perfektiv"}
		present_or_future_cell = {'!rowspan="3"', "Presens / Futurum"}
		pres_or_fut_sing_1_pers = forms.fut_sing_1_pers
		pres_or_fut_sing_2_pers = forms.fut_sing_2_pers
		pres_or_fut_sing_3_pers = forms.fut_sing_3_pers
		pres_or_fut_plur_1_pers = forms.fut_plur_1_pers
		pres_or_fut_plur_2_pers = forms.fut_plur_2_pers
		pres_or_fut_plur_3_pers = forms.fut_plur_3_pers
	end

	gt.setLanguage(lang_code_param)

	local str = ""

	str = str
	.. gt.getStart(number_of_columns, lang_code_param, part_of_speech_param, contains_a_quality_notice)
	.. gt.getRow({'!class="main min" colspan="2"', 'Böjningar av ' .. meta.pagename .. ' ' .. meta.meanings}, {'!rowspan="2"', 'Singular'}, {'!rowspan="2"', 'Plural'})
	.. gt.getRow(aspect_cell)
	.. gt.getRow(present_or_future_cell,         {'!', '1:a person'}, pres_or_fut_sing_1_pers, pres_or_fut_plur_1_pers)
	.. gt.getRow(                                {'!', '2:a person'}, pres_or_fut_sing_2_pers, pres_or_fut_plur_2_pers)
	.. gt.getRow(                                {'!', '3:e person'}, pres_or_fut_sing_3_pers, pres_or_fut_plur_3_pers)
	.. gt.getRow({'!rowspan="3"', "Preteritum"}, {'!', 'Maskulinum'}, forms.pret_sing_mask,   {'|rowspan="3"', forms.pret_plur})
	.. gt.getRow(                                {'!', 'Neutrum'},    forms.pret_sing_neutr)
	.. gt.getRow(                                {'!', 'Femininum'},  forms.pret_sing_fem)
	.. gt.getRow({'!', "Imperativ"},             {'!', '2:a person'}, forms.imp_sing, forms.imp_plur)
	.. table_section_divider
	.. gt.getRow({'!', "Particip"},   {'!', "Aktiv"},                                                          {'!', "Passiv"},                                                          {'!', "Gerundium"})
	
	if aspect == "impf" or aspect == "impfpf" then
		str = str
		.. gt.getRow({'!', "Presens"},    {'|', forms.x_pres_part_active, type='prespartakt'}, {'|', forms.x_pres_part_passive, type='prespartpass'}, {'|', forms.x_pres_gerund, type='presger'})
	end
	
	str = str
	.. gt.getRow({'!', "Preteritum"}, {'|', forms.x_pret_part_active, type='pretpartakt'}, {'|', forms.x_pret_part_passive, type='pretpartpass'}, {'|', forms.x_pret_gerund, type='pretger'})
	.. gt.getEnd(number_of_columns, note, as_first_part)

	return str
end

function export._getCategories(forms, meta)
	local basic_form_is_not_given = not meta.basic_form_is_given
	local one_or_more_forms_are_missing =
	forms.pres_sing_1_pers  == "?" or
	forms.pres_sing_2_pers  == "?" or
	forms.pres_sing_3_pers  == "?" or
	forms.pres_plur_1_pers  == "?" or
	forms.pres_plur_2_pers  == "?" or
	forms.pres_plur_3_pers  == "?" or
	forms.fut_sing_1_pers   == "?" or
	forms.fut_sing_2_pers   == "?" or
	forms.fut_sing_3_pers   == "?" or
	forms.fut_plur_1_pers   == "?" or
	forms.fut_plur_2_pers   == "?" or
	forms.fut_plur_3_pers   == "?" or
	forms.pret_sing_mask    == "?" or
	forms.pret_sing_neutr   == "?" or
	forms.pret_sing_fem     == "?" or
	forms.pret_plur         == "?" or
	forms.imp_sing          == "?" or
	forms.imp_plur          == "?" or
	forms.x_pres_part_active  == "?" or
	forms.x_pret_part_active  == "?" or
	forms.x_pres_part_passive == "?" or
	forms.x_pret_part_passive == "?" or
	forms.x_pres_gerund       == "?" or
	forms.x_pret_gerund       == "?"
	
	local str = ""
	if one_or_more_forms_are_missing then
		str = str .. "[[Kategori:Wiktionary:ru-verb/Former saknas]]"
	end

	if basic_form_is_not_given then
		str = str .. "[[Kategori:Wiktionary:ru-verb/Grundform ej angiven]]"
	end

	return str
end

return export