Mòdul:rmq-x-ca-verb

Icona de documentació de mòdul Documentació del mòdul[mostra] [modifica] [refresca]

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Mòdul de suport per la plantilla {{rmq-x-ca-conj}} que formata una taula de conjugació d’un verb en caló català. Vegeu la plantilla per al seu ús.

local p = {}

local m_links = require("Mòdul:enllaç")
local lang = {code = "rmq-x-ca", name = "caló català", sc = "Latn"}
local inflections = {}

local function get_data(args, data)
	local function alt_forms(current)
		local ret = {}
		local i = ''
		while args[current .. i] do
			local form = mw.text.split(args[current .. i], " %(") -- form (transliteration)
			if form[2] then
				table.insert(ret, {form[1], "(" .. form[2]})
			else
				table.insert(ret, {form[1]})
			end
			i = (tonumber(i) or 1) + 1
		end
		
		return ret
	end
	
	-- Non-finite forms
	data.inf = alt_forms("inf")
	data.ger = alt_forms("ger")
	data.part = alt_forms("part")
	data.imp = alt_forms("imp")
	
	-- Present
	data.pres_ind = {}
	data.pres_ind[1] = alt_forms("pres1s")
	data.pres_ind[2] = alt_forms("pres2s")
	data.pres_ind[3] = alt_forms("pres3s")
	data.pres_ind[4] = alt_forms("pres1p")
	data.pres_ind[5] = alt_forms("pres2p")
	data.pres_ind[6] = alt_forms("pres3p")
	
	-- Imperfect
	data.impf_ind = {}
	data.impf_ind[1] = alt_forms("imperf1s")
	data.impf_ind[2] = alt_forms("imperf2s")
	data.impf_ind[3] = alt_forms("imperf3s")
	data.impf_ind[4] = alt_forms("imperf1p")
	data.impf_ind[5] = alt_forms("imperf2p")
	data.impf_ind[6] = alt_forms("imperf3p")
	
	-- Past historic
	data.pass = {}
	data.pass[1] = alt_forms("pass1s")
	data.pass[2] = alt_forms("pass2s")
	data.pass[3] = alt_forms("pass3s")
	data.pass[4] = alt_forms("pass1p")
	data.pass[5] = alt_forms("pass2p")
	data.pass[6] = alt_forms("pass3p")
	
	-- Future
	data.fut = {}
	data.fut[1] = alt_forms("fut1s")
	data.fut[2] = alt_forms("fut2s")
	data.fut[3] = alt_forms("fut3s")
	data.fut[4] = alt_forms("fut1p")
	data.fut[5] = alt_forms("fut2p")
	data.fut[6] = alt_forms("fut3p")
	
	-- Conditional
	data.cond = {}
	data.cond[1] = alt_forms("cond1s")
	data.cond[2] = alt_forms("cond2s")
	data.cond[3] = alt_forms("cond3s")
	data.cond[4] = alt_forms("cond1p")
	data.cond[5] = alt_forms("cond2p")
	data.cond[6] = alt_forms("cond3p")
	
	-- Present subjunctive
	data.pres_subj = {}
	data.pres_subj[1] = alt_forms("sub1s")
	data.pres_subj[2] = alt_forms("sub2s")
	data.pres_subj[3] = alt_forms("sub3s")
	data.pres_subj[4] = alt_forms("sub1p")
	data.pres_subj[5] = alt_forms("sub2p")
	data.pres_subj[6] = alt_forms("sub3p")
	
	-- Imperfect subjunctive
	data.impf_subj = {}
	data.impf_subj[1] = alt_forms("impsub1s")
	data.impf_subj[2] = alt_forms("impsub2s")
	data.impf_subj[3] = alt_forms("impsub3s")
	data.impf_subj[4] = alt_forms("impsub1p")
	data.impf_subj[5] = alt_forms("impsub2p")
	data.impf_subj[6] = alt_forms("impsub3p")
end

-- Shows forms with links, or a dash if empty
local function show_form(subforms, param)
	local ret = {}
	
	-- Go over each subform and insert links
	for key, subform in ipairs(subforms) do
		if subform[2] then
			table.insert(ret, m_links.full_link({lang = lang, term = subform[1]}) .. " " .. subform[2])
		else
			table.insert(ret, m_links.full_link({lang = lang, term = subform[1]}))
		end
	end
	
	return table.concat(ret, ", ")
end

local function void_table(tt)
	for _, t in ipairs(tt) do
		if #t > 0 then
			return false
		end
	end
	return true
end

-- Shows the table with the given forms
local function make_table(data)
	local ret = {}
	table.insert(ret, '{| class="inflection-table, wikitable"')
	table.insert(ret, '! !! man !! tuquis !! ell/ella !! nosaltros !! vosaltros || ellos/elles')
	if not void_table(data.pres_ind) then
		table.insert(ret, '|-')
		table.insert(ret, '! present d’ind.')
		table.insert(ret, '| ' .. show_form(data.pres_ind[1])
			.. '|| ' .. show_form(data.pres_ind[2])
			.. '|| ' .. show_form(data.pres_ind[3])
			.. '|| ' .. show_form(data.pres_ind[4])
			.. '|| ' .. show_form(data.pres_ind[5])
			.. '|| ' .. show_form(data.pres_ind[6]))
	end
	if not void_table(data.impf_ind) then
		table.insert(ret, '|-')
		table.insert(ret, '! imperfet d’ind.')
		table.insert(ret, '| ' .. show_form(data.impf_ind[1])
			.. '|| ' .. show_form(data.impf_ind[2])
			.. '|| ' .. show_form(data.impf_ind[3])
			.. '|| ' .. show_form(data.impf_ind[4])
			.. '|| ' .. show_form(data.impf_ind[5])
			.. '|| ' .. show_form(data.impf_ind[6]))
	end
	if not void_table(data.pass) then
		table.insert(ret, '|-')
		table.insert(ret, '! passat')
		table.insert(ret, '| ' .. show_form(data.pass[1])
			.. '|| ' .. show_form(data.pass[2])
			.. '|| ' .. show_form(data.pass[3])
			.. '|| ' .. show_form(data.pass[4])
			.. '|| ' .. show_form(data.pass[5])
			.. '|| ' .. show_form(data.pass[6]))
	end
	if not void_table(data.fut) then
		table.insert(ret, '|-')
		table.insert(ret, '! futur')
		table.insert(ret, '| ' .. show_form(data.fut[1])
			.. '|| ' .. show_form(data.fut[2])
			.. '|| ' .. show_form(data.fut[3])
			.. '|| ' .. show_form(data.fut[4])
			.. '|| ' .. show_form(data.fut[5])
			.. '|| ' .. show_form(data.fut[6]))
	end
	if not void_table(data.cond) then
		table.insert(ret, '|-')
		table.insert(ret, '! condicional')
		table.insert(ret, '| ' .. show_form(data.cond[1])
			.. '|| ' .. show_form(data.cond[2])
			.. '|| ' .. show_form(data.cond[3])
			.. '|| ' .. show_form(data.cond[4])
			.. '|| ' .. show_form(data.cond[5])
			.. '|| ' .. show_form(data.cond[6]))
	end
	if not void_table(data.pres_subj) then
		table.insert(ret, '|-')
		table.insert(ret, '! present de subj.')
		table.insert(ret, '| ' .. show_form(data.pres_subj[1])
			.. '|| ' .. show_form(data.pres_subj[2])
			.. '|| ' .. show_form(data.pres_subj[3])
			.. '|| ' .. show_form(data.pres_subj[4])
			.. '|| ' .. show_form(data.pres_subj[5])
			.. '|| ' .. show_form(data.pres_subj[6]))
	end
	if not void_table(data.impf_subj) then
		table.insert(ret, '|-')
		table.insert(ret, '! imperfet de subj.')
		table.insert(ret, '| ' .. show_form(data.impf_subj[1])
			.. '|| ' .. show_form(data.impf_subj[2])
			.. '|| ' .. show_form(data.impf_subj[3])
			.. '|| ' .. show_form(data.impf_subj[4])
			.. '|| ' .. show_form(data.impf_subj[5])
			.. '|| ' .. show_form(data.impf_subj[6]))
	end
	if #data.imp > 0 then
		table.insert(ret, '|-')
		table.insert(ret, '! imperatiu')
		table.insert(ret, '| '
			.. '|| colspan="5" | ' .. show_form(data.imp))
	end
	if #data.inf > 0 then
		table.insert(ret, '|-')
		table.insert(ret, '! infinitiu')
		table.insert(ret, '| colspan="6" | ' .. show_form(data.inf))
	end
	if #data.ger > 0 then
		table.insert(ret, '|-')
		table.insert(ret, '! gerundi')
		table.insert(ret, '| colspan="6" | ' .. show_form(data.ger))
	end
	if #data.part > 0 then
		table.insert(ret, '|-')
		table.insert(ret, '! participi')
		table.insert(ret, '| colspan="6" | ' .. show_form(data.part))
	end
	table.insert(ret, '|}')
	return table.concat(ret, '\n')
end

-- Main entry point
function p.conj(frame)
	local args = frame:getParent().args
	
	local data = {}
	get_data(args, data)
	
	return make_table(data, args)
end

return p