Модуль:conj eo

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

Модуль, для определения основы глаголов эсперанто, необходимой для спряжения этих глаголов

Заготовка для копирования

{{#invoke:conj eo|verb_base|s=<!-- глагол -->}}

Тест модуля

Вызов Результат Должно быть
{{#invoke:conj eo|verb_base|s=fari}}
far far
{{#invoke:conj eo|verb_base|s=faris}}
far far
{{#invoke:conj eo|verb_base|s=faras}}
far far
{{#invoke:conj eo|verb_base|s=faros}}
far far
{{#invoke:conj eo|verb_base|s=faru}}
far far
{{#invoke:conj eo|verb_base|s=farus}}
far far
local p = {}

local present_tense = "форма настоящего времени"
local past_tense = "форма прошедшего времени, "
local future_tense = "форма будущего времени, "
local nom_sg= "именительного падежа, единственного числа, "
local nom_pl= "именительного падежа, множественного числа, "
local acc_sg= "винительного падежа, единственного числа, "
local acc_pl= "винительного падежа, множественного числа, "
local part = "Причастие, "
local ppart = "Страдательное причастие, "
local spart =  "Субстантивированное причастие, "
local sppart = "Субстантивированное страдательное причастие, "
local part2 = "Деепричастие" 
local ppart2 = "Страдательное деепричастие"
local verb = "глагола "
local from_verb = "образованное от глагола "
local tabl = 
{
	['i'] 		= 'Форма глагола: инфинитив.',
	['u'] 		= 'Форма повелительного наклонения глагола ', 
	['is'] 		= 'Форма прошедшего времени глагола ',
	['as'] 		= 'Форма настоящего времени глагола ',
	['os'] 		= 'Форма будущего времени глагола ',
	['as'] 		= 'Форма условного наклонения глагола ',
	['us'] 		= 'Форма сослагательного наклонения глагола ',
	['inta'] 	= part .. past_tense    .. nom_sg .. from_verb,
	['anta'] 	= part .. present_tense .. nom_sg .. from_verb,
	['onta'] 	= part .. future_tense  .. nom_sg .. from_verb,
	['intaj'] 	= part .. past_tense    .. nom_pl .. from_verb,
	['antaj'] 	= part .. present_tense .. nom_pl .. from_verb,
	['ontaj'] 	= part .. future_tense  .. nom_pl .. from_verb,
	['intan'] 	= part .. past_tense    .. acc_sg .. from_verb,
	['antan'] 	= part .. present_tense .. acc_sg .. from_verb,
	['ontan'] 	= part .. future_tense  .. acc_sg .. from_verb,
	['intajn'] 	= part .. past_tense    .. acc_pl .. from_verb,
	['antajn'] 	= part .. present_tense .. acc_pl .. from_verb,
	['ontajn'] 	= part .. future_tense  .. acc_pl .. from_verb,
	['ita'] 	= ppart .. past_tense    .. nom_sg .. from_verb,
	['ata'] 	= ppart .. present_tense .. nom_sg .. from_verb,
	['ota'] 	= ppart .. future_tense  .. nom_sg .. from_verb,
	['itaj'] 	= ppart .. past_tense    .. nom_pl .. from_verb,
	['ataj'] 	= ppart .. present_tense .. nom_pl .. from_verb,
	['otaj'] 	= ppart .. future_tense  .. nom_pl .. from_verb,
	['itan'] 	= ppart .. past_tense    .. acc_sg .. from_verb,
	['atan'] 	= ppart .. present_tense .. acc_sg .. from_verb,
	['otan'] 	= ppart .. future_tense  .. acc_sg .. from_verb,
	['itajn'] 	= ppart .. past_tense    .. acc_pl .. from_verb,
	['atajn'] 	= ppart .. present_tense .. acc_pl .. from_verb,
	['otajn'] 	= ppart .. future_tense  .. acc_pl .. from_verb,
	['into'] 	= spart .. past_tense    .. nom_sg .. from_verb,
	['anto'] 	= spart .. present_tense .. nom_sg .. from_verb,
	['onto'] 	= spart .. future_tense  .. nom_sg .. from_verb,
	['intoj'] 	= spart .. past_tense    .. nom_pl .. from_verb,
	['antoj'] 	= spart .. present_tense .. nom_pl .. from_verb,
	['ontoj'] 	= spart .. future_tense  .. nom_pl .. from_verb,
	['inton'] 	= spart .. past_tense    .. acc_sg .. from_verb,
	['anton'] 	= spart .. present_tense .. acc_sg .. from_verb,
	['onton'] 	= spart .. future_tense  .. acc_sg .. from_verb,
	['intojn'] 	= spart .. past_tense    .. acc_pl .. from_verb,
	['antojn'] 	= spart .. present_tense .. acc_pl .. from_verb,
	['ontojn'] 	= spart .. future_tense  .. acc_pl .. from_verb,
	['ito'] 	= sppart .. past_tense    .. nom_sg .. from_verb,
	['ato'] 	= sppart .. present_tense .. nom_sg .. from_verb,
	['oto'] 	= sppart .. future_tense  .. nom_sg .. from_verb,
	['itoj'] 	= sppart .. past_tense    .. nom_pl .. from_verb,
	['atoj'] 	= sppart .. present_tense .. nom_pl .. from_verb,
	['otoj'] 	= sppart .. future_tense  .. nom_pl .. from_verb,
	['iton'] 	= sppart .. past_tense    .. acc_sg .. from_verb,
	['aton'] 	= sppart .. present_tense .. acc_sg .. from_verb,
	['oton'] 	= sppart .. future_tense  .. acc_sg .. from_verb,
	['itojn'] 	= sppart .. past_tense    .. acc_pl .. from_verb,
	['atojn'] 	= sppart .. present_tense .. acc_pl .. from_verb,
	['otojn']	= sppart .. future_tense  .. acc_pl .. from_verb,
	['inte'] 	= part2 .. past_tense .. from_verb, 
	['ante'] 	= part2 .. present_tense .. from_verb,
	['onte'] 	= part2 .. future_tense .. from_verb,
	['ite'] 	= ppart2 .. past_tense .. from_verb, 
	['ate'] 	= ppart2 .. present_tense .. from_verb,
	['ote'] 	= ppart2 .. future_tense .. from_verb,
}

function p.get_description( frame )
	local new_args = p._getParameters( frame.args, {'s'} )
    local s = new_args['s'] or ''

	local base = p._verb_base( s );
	local s_end = mw.ustring.gsub(s, "^" .. base .. "(.+)$", '%1', 1)
	
	local description = tabl[s_end];
	if description ~=  nil then
		return description .. '[[' .. p._verb_base( s ) .. 'i#Эсперанто|' .. base .. 'i]]'
	end
    return ''
end

function p.verb_base( frame )
	local new_args = p._getParameters( frame.args, {'s'} )
    local s = new_args['s'] or ''
    
    return p._verb_base( s )
end

function p._verb_base( s )
	local result, cnt = mw.ustring.gsub(s, '^(.+)[iao]n?t[aoe]j?n?$', '%1', 1)
	if cnt == 0 then
		result, cnt = mw.ustring.gsub(s, '^(.+)[iaou]s$', '%1', 1)
		if cnt == 0 then
			result = mw.ustring.gsub(s, '^(.+).$', '%1', 1)	
		end
	end
	return result;
end

function p.getConjTable(frame)
	local template = 'спряжение eo'
	local new_args = p._getParameters( frame.args, {'v', 'p'} )
	local v = new_args['v'] or ''
	local per = new_args['p'] or ''
    
	local base = p._verb_base( v )
	local t = {
    	['a'] = "á", ['A'] = 'Á', ['o'] = 'ó', ['O'] = 'Ó', 
    	['e'] = "é", ['E'] = 'É', ['i'] = 'í', ['I'] = 'Í',
    	['u'] = 'ú', ['U'] = 'Ú' }
	local baseu, cnt = mw.ustring.gsub(base, "^(.*)([AaOoEeIiUu])([^AaOoEeIiUu]+)$", function (before, ch, after)
	    	return before .. t[ch] .. after
	    end, 1)
    
	return frame:expandTemplate{ title = template, args = { ['основа'] = base, ['основауд'] = baseu, ['P'] = per } };
end

function p._getParameters( frame_args, arg_list )
    local new_args = {};
    local index = 1;
    local value;
 
    for i,arg in ipairs( arg_list ) do
        value = frame_args[arg]
        if value == nil then
            value = frame_args[index];
            index = index + 1;
        end
        new_args[arg] = value;
    end
 
    return new_args;
end  

return p