Mòdul:roa-oca-verb

De Viccionari
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 {{roa-oca-conj}} per a generar la taula de conjugació antiga d’un verb en català antic. Vegeu la plantilla per al seu ús.

Les taules es construeixen a base de verbs model definits en subpàgines d’aquest mòdul. Models disponibles:

Addicionalment, amb el paràmetre bot=1, o qualsevol valor, genera una llista per a facilitar la lectura per un bot.

local p = {}

local lang = {code = "roa-oca", name = "català antic", sc = "Latn"}

-- This generates machine-readable output, which allows formbots to easily
-- parse the output of the module.
local function make_bot_list(forma)
	local ret = ""
	
	for key1, form1 in pairs(forma) do --temps
		for key2, form2 in pairs(form1) do -- fila
			for key3, form3 in pairs(form2) do -- persona
				ret = ret .. "* " .. key1 .. "-" .. key3 .. "=" .. form3 .. "\n"
			end
		end
	end
	
	return ret
end

local function make_rows_ger(forma)
	local ret = ""
	if #forma.ger > 0 then
		for i, v in ipairs(forma.ger) do
			ret = ret .. '| colspan="6" | ' .. forma.ger[i][1] .. [=[ 
				|-
				]=]
		end
	else
		ret = '| colspan="6" | -' .. [=[ 
			|-
			]=]
	end
	return ret
end

local function make_rows_part(forma)
	local ret = ""
	if #forma.part > 0 then
		for i, v in ipairs(forma.part) do
			ret = ret .. '| colspan="6" | ' .. forma.part[i]["m-s"]
			if forma.part[i]["f-s"] then
				ret = ret .. ", " .. forma.part[i]["f-s"] .. ", " .. (forma.part[i]["m-p"] or "-") .. ", " .. (forma.part[i]["f-p"] or "-")
			end
			ret = ret .. [=[ 
				|-
				]=]
		end
	else
		ret = '| colspan="6" | -' .. [=[ 
			|-
			]=]
	end
	return ret
end

local function make_rows_6(forma, temps)
	local ret = ""
	if #forma[temps] > 0 then
		for i, v in ipairs(forma[temps]) do
			local rowstyle = '| '
			if i == 1 and string.sub(temps, 1, 4) ~= "pres" then
				rowstyle = '| style="border-top: 1px solid grey" | '
			end
			for j = 1, 6 do
				ret = ret .. rowstyle .. (forma[temps][i][j] or (i == 1 and "–" or "")) .. [=[ 
					]=]
			end
			ret = ret .. [=[ 
				|-
				]=]
		end
	else
		for j = 1, 6 do
			ret = ret .. '| style="border: 1px solid grey" | -' .. [=[ 
			]=]
		end
		ret = ret .. [=[ 
			|-
			]=]
	end
	return ret
end

local function make_rows_imp(forma)
	local ret = ""
	if #forma.imp > 0 then
		for i, v in ipairs(forma.imp) do
			ret = ret .. '| –' .. [=[ 
				]=]
			for j = 2, 6 do
				ret = ret .. '| ' .. (forma.imp[i][j] or "") .. [=[ 
					]=]
			end
			ret = ret .. [=[ 
				|-
				]=]
		end
	else
		ret = ret .. '| –' .. [=[ 
				]=]
		for j = 2, 6 do
			ret = ret .. '| -' .. [=[ 
				]=]
		end
		ret = ret .. [=[ 
			|-
			]=]
	end
	return ret
end

local function make_table(forma, infinitiu)
	-- Make links out of all forms
	for key1, form1 in pairs(forma) do -- temps
		for key2, form2 in pairs(form1) do -- fila
			for key3, form3 in pairs(form2) do -- persona
				forma[key1][key2][key3] = require("Mòdul:enllaç").full_link({lang = lang, term = form3})
			end
		end
	end
	
	local title = "Conjugació antiga"
	return [=[
<div class="NavFrame" style="clear:right">
<div class="NavHead" style="background: #efefef"><span style="margin-left:1em; font-style:italic;">]=] .. title .. [=[</span></div>
<div class="NavContent">
{| class="conjugacions" style="width:100%; background:#F0F0F0; padding:.3em; text-align:left;"
! colspan="7" style="background:#C0C0C0" | Formes no personals
|-
! style="background:#e2e4c0;" | infinitiu
| colspan="6" | [[]=] .. infinitiu .. "]]" .. [=[ 
|- 
! rowspan="]=] .. (#forma.ger > 0 and #forma.ger or "1") .. [=[" style="background:#e2e4c0;" | gerundi
]=] .. make_rows_ger(forma) .. [=[ 
! rowspan="]=] .. (#forma.part > 0 and #forma.part or "1") .. [=[" style="background:#e2e4c0;" | participi
]=] .. make_rows_part(forma) .. [=[ 
! colspan="7" style="background:#C0C0C0;" | Formes personals simples
|- 
! style="background:#c0cfe4;" | indicatiu
! style="background:#c0cfe4;" | io, yo, jo
! style="background:#c0cfe4;" | tu
! style="background:#c0cfe4;" | él, eyl, ell
! style="background:#c0cfe4;" | nós, nosaltres
! style="background:#c0cfe4;" | vós, vosaltres
! style="background:#c0cfe4;" | éls, eyls, ells
|- 
! rowspan="]=] .. (#forma["pres-ind"] > 0 and #forma["pres-ind"] or "1") .. [=[" style="height:3em; background:#c0cfe4;" | present
]=] .. make_rows_6(forma, "pres-ind") .. [=[ 
! rowspan="]=] .. (#forma["imperf-ind"] > 0 and #forma["imperf-ind"] or "1") .. [=[" style="height:3em; background:#c0cfe4;" | imperfet
]=] .. make_rows_6(forma, "imperf-ind") .. [=[ 
! rowspan="]=] .. (#forma.pass > 0 and #forma.pass or "1") .. [=[" style="height:3em; background:#c0cfe4;" | passat simple
]=] .. make_rows_6(forma, "pass") .. [=[ 
! rowspan="]=] .. (#forma.fut > 0 and #forma.fut or "1") .. [=[" style="height:3em; background:#c0cfe4;" | futur
]=] .. make_rows_6(forma, "fut") .. [=[ 
! rowspan="]=] .. (#forma.cond > 0 and #forma.cond or "1") .. [=[" style="height:3em; background:#c0cfe4;" | condicional
]=] .. make_rows_6(forma, "cond") .. [=[ 
! style="background:#c0e4c0;" | subjuntiu
! style="background:#c0e4c0;" | io, yo, jo
! style="background:#c0e4c0;" | tu
! style="background:#c0e4c0;" | él, eyl, ell
! style="background:#c0e4c0;" | nós, nosaltres
! style="background:#c0e4c0;" | vós, vosaltres
! style="background:#c0e4c0;" | éls, eyls, ells
|-
! rowspan="]=] .. (#forma["pres-subj"] > 0 and #forma["pres-subj"] or "1") .. [=[" style="height:3em; background:#c0e4c0;" | present
]=] .. make_rows_6(forma, "pres-subj") .. [=[ 
! rowspan="]=] .. (#forma["imperf-subj"] > 0 and #forma["imperf-subj"] or "1") .. [=[" style="height:3em; background:#c0e4c0;" | imperfet
]=] .. make_rows_6(forma, "imperf-subj") .. [=[ 
! style="background:#e4d4c0;" | imperatiu
! style="background:#e4d4c0;" | &ndash;
! style="background:#e4d4c0;" | tu
! style="background:#e4d4c0;" | él, eyl, ell
! style="background:#e4d4c0;" | nós, nosaltres
! style="background:#e4d4c0;" | vós, vosaltres
! style="background:#e4d4c0;" | éls, eyls, ells
|- 
! rowspan="]=] .. (#forma.imp > 0 and #forma.imp or "1") .. [=[" style="height:3em; background:#e4d4c0;" | present
]=] .. make_rows_imp(forma) .. [=[ 
|}
</div></div>]=]
end

function p.show(frame)
	local args = frame:getParent().args
	local pagename = args.pagename or mw.title.getCurrentTitle().subpageText
	local NAMESPACE = mw.title.getCurrentTitle().nsText
	local infinitiu = args.inf or pagename
	local model = args[1] or ""
	if model == "" then return end
	
	local forma = require("Module:roa-oca-verb/" .. model).formes(infinitiu)
	
	if args.bot then
		return make_bot_list(forma)
	else
		return make_table(forma, infinitiu)
	end
end

return p