Mòdul:ca-verb/taula

De Viccionari

La documentació d'ús d'aquest mòdul es pot crear a Mòdul:ca-verb/taula/ús

-- Make the table
local p = {}

local function formesDefectives(tipus)
	local defectius = {}
	if tipus == "36" then
		defectius = require("Mòdul:utilitats").llista({1, 2, 4, 5, "m-p", "f-s", "f-p", "imp"})
	elseif tipus == "3" then
		defectius = require("Mòdul:utilitats").llista({1, 2, 4, 5, 6, "m-p", "f-s", "f-p", "imp"})
	elseif tipus == "part" then
		defectius = require("Mòdul:utilitats").llista({1, 2, 3, 4, 5, 6, "ger", "imp"})
	end
	
	return defectius
end

-- Formes del paradigma: present d'indicatiu 1, 3, 4
local function paradigma(forma, defectius, pp, pp_el)
	local paradigma = {}
	paradigma[1] = forma["pres-ind"][1][1]
	paradigma[2] = forma["pres-ind"][1][3]
	paradigma[3] = forma["pres-ind"][1][4]
	if paradigma[1] and paradigma[2] and paradigma[3] then
		if not defectius[1] then
			paradigma[1] = (paradigma[1]:find("^[aeiouh]") and pp_el[1] or pp[1]) .. '[[' .. paradigma[1] .. ']]'
		end
		if not defectius[3] then
			paradigma[2] = (paradigma[2]:find("^[aeiouh]") and pp_el[3] or pp[3]) .. '[[' .. paradigma[2] .. ']]'
		end
		if not defectius[4] then
			paradigma[3] = (paradigma[3]:find("^[aeiouh]") and pp_el[4] or pp[4]) .. '[[' .. paradigma[3] .. ']]'
		end
		return "Paradigmes de flexió: " .. table.concat(paradigma, ", ")
	end
	return ''
end

local function rizo(vocal)
	if vocal == nil then return '' end
	
	local text = "<br />Vocal rizotònica: "
	if vocal == "é" then
		return text .. "/e/"
	elseif vocal == "è" then
		return text .. "/ɛ/"
	elseif vocal == "ê" then
		return text .. "/ɛ/, /ə/, /e/"
	elseif vocal == "ë" then
		return text .. "/ɛ/, /e/"
	elseif vocal == "ó" then
		return text .. "/o/"
	elseif vocal == "ò" then
		return text .. "/ɔ/"
	elseif vocal == "ô" then
		return text .. "/ɔ/, /o/"
	else
		return text .. vocal
	end
end

local function makeRowsGer(forma, part, vpron)
	local ret = '| colspan="3" | ' .. (forma.ger[1] and (forma.ger[1][1] or "-") or "-") .. [=[ 
		| colspan="4" | havent]=] .. vpron .. " " .. (part or "-") .. [=[ 
		|- 
		]=]
	if forma.ger[2] then
		ret = ret .. '| colspan="6" | ' .. forma.ger[2][1].. [=[ 
			| style="font-style:italic;" | ]=] .. (forma.ger[2]["nota"] or "") .. [=[ 
			|-
			]=]
	end
	return ret
end

local function makeRowsPart(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 .. [=[ 
				| style="font-style:italic;" | ]=] .. (forma.part[i]["nota"] or "") .. [=[ 
				|-
				]=]
		end
	else
		ret = '| colspan="7" | -' .. [=[ 
			|-
			]=]
	end
	return ret
end

local function makeRows6(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 "") .. [=[ 
					]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma[temps][i]["nota"] or "") .. [=[ 
				|-
				]=]
		end
	else
		for j = 1, 6 do
			ret = ret .. '| style="border: 1px solid grey" | -' .. [=[ 
			]=]
		end
		ret = ret .. [=[ 
			|-
			]=]
	end
	return ret
end

local function makeRowsImp(forma)
	local ret = ""
	if #forma.imp > 0 then
		for i, v in ipairs(forma.imp) do
			ret = ret .. '| &ndash;' .. [=[ 
				]=]
			for j = 2, 6 do
				ret = ret .. '| ' .. (forma.imp[i][j] or "") .. [=[ 
					]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma.imp[i]["nota"] or "") .. [=[ 
				|-
				]=]
		end
	else
		ret = ret .. '| &ndash;' .. [=[ 
				]=]
		for j = 2, 6 do
			ret = ret .. '| -' .. [=[ 
				]=]
		end
		ret = ret .. [=[ 
			|-
			]=]
	end
	return ret
end

local function makeSimples(forma, part, title, vpron)

	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:#C0C0C0; text-align:center;" | ''[[Viccionari:Conjugació|Notes]]''
|- 
! style="background:#e2e4c0;" | 
! colspan="3" style="background:#e2e4c0;" | simples
! colspan="3" style="background:#e2e4c0;" | compostes
|-
! style="background:#e2e4c0;" | infinitiu
| colspan="3" | [[]=] .. forma.inf .. "]]" .. (vpron == "-se" and (forma.inf:find("[aeiou]$") and "'s" or "-se") or vpron) .. [=[ 
| colspan="3" | haver]=] .. vpron .. " " .. (part or "-") .. [=[ 
|- 
! rowspan="]=] .. (#forma.ger > 0 and #forma.ger or "1") .. [=[" style="background:#e2e4c0;" | gerundi
]=] .. makeRowsGer(forma, part, vpron) .. [=[ 
! rowspan="]=] .. (#forma.part > 0 and #forma.part or "1") .. [=[" style="background:#e2e4c0;" | participi
]=] .. makeRowsPart(forma) .. [=[ 
! colspan="7" style="background:#C0C0C0;" | Formes personals simples
|- 
! style="background:#c0cfe4;" | indicatiu
! style="background:#c0cfe4;" | jo
! style="background:#c0cfe4;" | tu
! style="background:#c0cfe4;" | ell/ella/vostè
! style="background:#c0cfe4;" | nosaltres
! style="background:#c0cfe4;" | vosaltres/vós
! style="background:#c0cfe4;" | ells/elles/vostès
|- 
! rowspan="]=] .. (#forma["pres-ind"] > 0 and #forma["pres-ind"] or "1") .. [=[" style="height:3em; background:#c0cfe4;" | present
]=] .. makeRows6(forma, "pres-ind") .. [=[ 
! rowspan="]=] .. (#forma["imperf-ind"] > 0 and #forma["imperf-ind"] or "1") .. [=[" style="height:3em; background:#c0cfe4;" | imperfet
]=] .. makeRows6(forma, "imperf-ind") .. [=[ 
! rowspan="]=] .. (#forma.pass > 0 and #forma.pass or "1") .. [=[" style="height:3em; background:#c0cfe4;" | passat simple
]=] .. makeRows6(forma, "pass") .. [=[ 
! rowspan="]=] .. (#forma.fut > 0 and #forma.fut or "1") .. [=[" style="height:3em; background:#c0cfe4;" | futur
]=] .. makeRows6(forma, "fut") .. [=[ 
! rowspan="]=] .. (#forma.cond > 0 and #forma.cond or "1") .. [=[" style="height:3em; background:#c0cfe4;" | condicional
]=] .. makeRows6(forma, "cond") .. [=[ 
! style="background:#c0e4c0;" | subjuntiu
! style="background:#c0e4c0;" | jo
! style="background:#c0e4c0;" | tu
! style="background:#c0e4c0;" | ell/ella/vostè
! style="background:#c0e4c0;" | nosaltres
! style="background:#c0e4c0;" | vosaltres/vós
! style="background:#c0e4c0;" | ells/elles/vostès
|-
! rowspan="]=] .. (#forma["pres-subj"] > 0 and #forma["pres-subj"] or "1") .. [=[" style="height:3em; background:#c0e4c0;" | present
]=] .. makeRows6(forma, "pres-subj") .. [=[ 
! rowspan="]=] .. (#forma["imperf-subj"] > 0 and #forma["imperf-subj"] or "1") .. [=[" style="height:3em; background:#c0e4c0;" | imperfet
]=] .. makeRows6(forma, "imperf-subj") .. [=[ 
! style="background:#e4d4c0;" | imperatiu
! style="background:#e4d4c0;" | &ndash;
! style="background:#e4d4c0;" | tu
! style="background:#e4d4c0;" | ell/ella/vostè
! style="background:#e4d4c0;" | nosaltres
! style="background:#e4d4c0;" | vosaltres/vós
! style="background:#e4d4c0;" | ells/elles/vostès
|- 
! rowspan="]=] .. (#forma.imp > 0 and #forma.imp or "1") .. [=[" style="height:3em; background:#e4d4c0;" | present
]=] .. makeRowsImp(forma) .. [=[ 
|-
| colspan="8" style="background:#efefef; text-align:center; border: 1px solid #8888aa; font-style:italic;" | ]=] .. (forma.nota or "") .. [=[ 
|}
</div></div>]=]
end

local function makeRowsGerPartNo(forma)
	local ret = ""
	if forma["no-ger"] then
		ret = ret .. [=[! style="background:#e2e4c0" | gerundi
		| colspan="6" | ]=] .. forma["no-ger"] .. [=[ 
		|-
		]=]
	end
	if forma["no-part"] then
		ret = ret .. [=[! style="background:#e2e4c0" | participi
		| colspan="6" | ]=] .. forma["no-part"]["m-s"] .. ", " .. forma["no-part"]["f-s"] .. ", " .. forma["no-part"]["m-p"].. ", " .. forma["no-part"]["f-p"]
		ret = ret .. [=[ 
		| style="font-style:italic;" | ]=] .. (forma["no-part"]["nota"] or "") .. [=[ 
		|-
		]=]
	end
	return ret
end

local function makeRowsPresNo(forma)
	local ret = ""
	if forma["no-pres-ind"] then
		ret = ret .. '! rowspan="' .. #forma["no-pres-ind"] .. [=[" style="height:3em; background:#c0cfe4;" | present 
		]=]
		for i, v in ipairs(forma["no-pres-ind"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-pres-ind"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-pres-ind"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsImperfindNo(forma)
	local ret = ""
	if forma["no-imperf-ind"] then
		ret = ret .. '! rowspan="' .. #forma["no-imperf-ind"] .. [=[" style="height:3em; background:#c0cfe4;" | imperfet 
		]=]
		for i, v in ipairs(forma["no-imperf-ind"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-imperf-ind"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-imperf-ind"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsPassNo(forma)
	local ret = ""
	if forma["no-pass"] then
		ret = ret .. '! rowspan="' .. #forma["no-pass"] .. [=[" style="height:3em; background:#c0cfe4;" | passat simple 
		]=]
		for i, v in ipairs(forma["no-pass"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-pass"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-pass"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsFutNo(forma)
	local ret = ""
	if forma["no-fut"] then
		ret = ret .. '! rowspan="' .. #forma["no-fut"] .. [=[" style="height:3em; background:#c0cfe4;" | futur 
		]=]
		for i, v in ipairs(forma["no-fut"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-fut"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-fut"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsCondNo(forma)
	local ret = ""
	if forma["no-cond"] then
		ret = ret .. '! rowspan="' .. #forma["no-cond"] .. [=[" style="height:3em; background:#c0cfe4;" | condicional 
		]=]
		for i, v in ipairs(forma["no-cond"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-cond"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-cond"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsPresssubjNo(forma)
	local ret = ""
	if forma["no-pres-subj"] then
		ret = ret .. '! rowspan="' .. #forma["no-pres-subj"] .. [=[" style="height:3em; background:#c0e4c0;" | present 
		]=]
		for i, v in ipairs(forma["no-pres-subj"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-pres-subj"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-pres-subj"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsImperfsubjNo(forma)
	local ret = ""
	if forma["no-imperf-subj"] then
		ret = ret .. '! rowspan="' .. #forma["no-imperf-subj"] .. [=[" style="height:3em; background:#c0e4c0;" | imperfet 
		]=]
		for i, v in ipairs(forma["no-imperf-subj"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-imperf-subj"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-imperf-subj"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeRowsImpNo(forma)
	local ret = ""
	if forma["no-imp"] then
		ret = ret .. [=[! style="background:#e4d4c0" | imperatiu
! style="background:#e4d4c0" | -
! style="background:#e4d4c0" | tu
! style="background:#e4d4c0" | ell/ella/vostè
! style="background:#e4d4c0" | nosaltres
! style="background:#e4d4c0" | vosaltres/vós
! style="background:#e4d4c0" | ells/elles/vostès
|- 
! rowspan="]=] .. #forma["no-imp"] .. [=[" style="height:3em; background:#e4d4c0" | present 
]=]
		for i, v in ipairs(forma["no-imp"]) do
			for j = 1, 6 do
				ret = ret .. '| ' .. (forma["no-imp"][i][j] or "") .. [=[ 
				]=]
			end
			ret = ret .. '| style="font-style:italic;" | ' .. (forma["no-imp"][i]["nota"] or "") .. [=[ 
			|-
			]=]
		end
	end
	return ret
end

local function makeAlternatives(forma)
	if not (forma["no-ger"] or forma["no-part"] or forma["no-pres-ind"] or forma["no-imperf-ind"] or forma["no-fut"] or forma["no-cond"]
		or forma["no-pres-subj"] or forma["no-imperf-subj"] or forma["no-imp"]) then
			return ""
	end
	return [=[
<div class="NavFrame" style="clear:right">
<div class="NavHead" style="background: #efefef"><span style="margin-left:2em; font-size:90%; font-style:italic;">Formes no normatives o col·loquials</span></div>
<div class="NavContent">
{| class="conjugacions" style="width:100%; background:#F0F0F0; padding:.3em; text-align:left;" 
]=] .. makeRowsGerPartNo(forma) .. [=[ 
! style="background:#c0cfe4;" | indicatiu
! style="background:#c0cfe4;" | jo
! style="background:#c0cfe4;" | tu
! style="background:#c0cfe4;" | ell/ella/vostè
! style="background:#c0cfe4;" | nosaltres
! style="background:#c0cfe4;" | vosaltres/vós
! style="background:#c0cfe4;" | ells/elles/vostès
|- 
]=] .. makeRowsPresNo(forma) .. [=[ 
]=] .. makeRowsImperfindNo(forma) .. [=[ 
]=] .. makeRowsPassNo(forma) .. [=[ 
]=] .. makeRowsFutNo(forma) .. [=[ 
]=] .. makeRowsCondNo(forma) .. [=[ 
! style="background:#c0e4c0;" | subjuntiu
! style="background:#c0e4c0;" | jo
! style="background:#c0e4c0;" | tu
! style="background:#c0e4c0;" | ell/ella/vostè
! style="background:#c0e4c0;" | nosaltres
! style="background:#c0e4c0;" | vosaltres/vós
! style="background:#c0e4c0;" | ells/elles/vostès
|-
]=] .. makeRowsPresssubjNo(forma) .. [=[ 
]=] .. makeRowsImperfsubjNo(forma) .. [=[ 
]=] .. makeRowsImpNo(forma) .. [=[ 
|}
</div></div>]=]
end

local function makeRowsComp(pers, pp, def)
	local ret = ""
	for j = 1, 6 do
		if def[j] then
			ret = ret .. '| -' .. [=[ 
				]=]
		else
			ret = ret .. '| ' .. (pers[j] and (pp[j] .. pers[j]) or "") .. [=[ 
				]=]
		end
	end
	return ret
end

local function makeCompostes(inf, part, pp_pro_ref, pp_pro_el, pp_pro_el_c, def)
	if not part then
		return ""
	end
	return [=[
<div class="NavFrame" style="clear:right">
<div class="NavHead" style="background: #efefef"><span style="margin-left:2em; font-size:90%; font-style:italic;">Formes compostes i perifràstiques</span></div>
<div class="NavContent">
{| class="conjugacions" style="width:100%; background:#F0F0F0; padding:.3em; text-align:left;"
! style="background:#c0cfe4;" | indicatiu
! style="background:#c0cfe4;" | jo
! style="background:#c0cfe4;" | tu
! style="background:#c0cfe4;" | ell/ella/vostè
! style="background:#c0cfe4;" | nosaltres
! style="background:#c0cfe4;" | vosaltres/vós
! style="background:#c0cfe4;" | ells/elles/vostès
! style="background:#c0cfe4;" | verb
|- 
! rowspan="2" style="height:3em; background:#c0cfe4;" | perfet
]=] .. makeRowsComp({"he", "has", "ha", "hem", "heu", "han"}, pp_pro_el_c, def) .. [=[ 
| rowspan="2" style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|- 
]=] .. makeRowsComp({nil, nil, nil, "havem", "haveu", nil}, pp_pro_el_c, def) .. [=[ 
|- 
! rowspan="2" style="height:3em; background:#c0cfe4;" | passat perifràstic
]=] .. makeRowsComp({"vaig", "vas", "va", "vam", "vau", "van"}, pp_pro_ref, def) .. [=[ 
| rowspan="2" style="background:#C0C0C0;" | ...]=] .. inf .. [=[ 
|- 
]=] .. makeRowsComp({nil, "vares", nil, "vàrem", "vàreu", "varen"}, pp_pro_ref, def) .. [=[ 
|- 
! style="height:3em; background:#c0cfe4;" | plusquamperfet
]=] .. makeRowsComp({"havia", "havies", "havia", "havíem", "havíeu", "havien"}, pp_pro_el_c, def) .. [=[ 
| style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|- 
! rowspan="3" style="height:3em; background:#c0cfe4;" | passat anterior<br />o perifràstic
]=] .. makeRowsComp({"haguí", "hagueres", "hagué", "haguérem", "haguéreu", "hagueren"}, pp_pro_el_c, def) .. [=[ 
| rowspan="3" style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|- 
]=] .. makeRowsComp({"vaig haver", "vas haver", "va haver", "vam haver", "vau haver", "van haver"}, pp_pro_ref, def) .. [=[ 
|- 
]=] .. makeRowsComp({nil, "vares haver", nil, "vàrem haver", "vàreu haver", "varen haver"}, pp_pro_ref, def) .. [=[ 
|- 
! style="height:3em; background:#c0cfe4;" | futur perfet
]=] .. makeRowsComp({"hauré", "hauràs", "haurà", "haurem", "haureu", "hauran"}, pp_pro_el_c, def) .. [=[ 
| style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|- 
! rowspan="2" style="height:3em; background:#c0cfe4;" | condicional perfet
]=] .. makeRowsComp({"hauria", "hauries", "hauria", "hauríem", "hauríeu", "haurien"}, pp_pro_el_c, def) .. [=[ 
| rowspan="2" style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|- 
]=] .. makeRowsComp({"haguera", "hagueres", "haguera", "haguérem", "haguéreu", "hagueren"}, pp_pro_el_c, def) .. [=[ 
|- 
! style="background:#c0e4c0" | subjuntiu
! style="background:#c0e4c0" | jo
! style="background:#c0e4c0" | tu
! style="background:#c0e4c0" | ell/ella/vostè
! style="background:#c0e4c0" | nosaltres
! style="background:#c0e4c0" | vosaltres/vós
! style="background:#c0e4c0" | ells/elles/vostès
! style="background:#c0e4c0" | verb
|- 
! rowspan="2" style="height:3em; background:#c0e4c0;" | passat perifràstic
]=] .. makeRowsComp({"vagi", "vagis", "vagi", "vàgim", "vàgiu", "vagin"}, pp_pro_ref, def) .. [=[ 
| rowspan="2" style="background:#C0C0C0;" | ...]=] .. inf .. [=[ 
|- 
]=] .. makeRowsComp({"vaja", "vages", "vaja", "vàgem", "vàgeu", "vagen"}, pp_pro_ref, def) .. [=[ 
|- 
! rowspan="2" style="height:3em; background:#c0e4c0;" | perfet
]=] .. makeRowsComp({"hagi", "hagis", "hagi", "hàgim", "hàgiu", "hagin"}, pp_pro_el_c, def) .. [=[ 
| rowspan="2" style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|- 
]=] .. makeRowsComp({"haja", "hages", "haja", "hàgem", "hàgeu", "hagen"}, pp_pro_el_c, def) .. [=[ 
|- 
! rowspan="3" style="height:3em; background:#c0e4c0;" | plusquamperfet
]=] .. makeRowsComp({"hagués", "haguessis", "hagués", "haguéssim", "haguéssiu", "haguessin"}, pp_pro_el_c, def) .. [=[ 
| rowspan="3" style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|-
]=] .. makeRowsComp({nil, "haguesses", nil, "haguéssem", "haguésseu", "haguessen"}, pp_pro_el_c, def) .. [=[ 
|- 
]=] .. makeRowsComp({"haguera", "hagueres", "haguera", "haguérem", "haguéreu", "hagueren"}, pp_pro_el_c, def) .. [=[ 
|- 
! rowspan="2" style="height:3em; background:#c0e4c0;" | passat anterior<br />perifràstic
]=] .. makeRowsComp({"vagi haver", "vagis haver", "vagi haver", "vàgim haver", "vàgiu haver", "vagin haver"}, pp_pro_ref, def) .. [=[ 
| rowspan="2" style="background:#C0C0C0;" | ...]=] .. part .. [=[ 
|-
]=] .. makeRowsComp({"vaja haver", "vages haver", "vaja haver", "vàgem haver", "vàgeu haver", "vagen haver"}, pp_pro_ref, def) .. [=[ 
|}
</div></div>]=]
end

-- This generates machine-readable output, which allows formbots to easily
-- parse the output of the module.
function p.make_bot_list(forma, def)
	local defectius = formesDefectives(def)
	local ret = ""
	
	for key1, form1 in pairs(forma) do
		if type(form1) == "table" then
			for key2, form2 in pairs(form1) do
				if type(form2) == "table" then
					for key3, form3 in pairs(form2) do
						if key3 ~= "nota" and not (defectius[key3] or defectius[key1]) then
							ret = ret .. "* " .. key1 .. "-" .. key3 .. "=" .. form3 .. "(" .. (form2.nota or "") .. ")\n"
						end
					end
				elseif key2 ~= "nota" and not (defectius[key2] or defectius[key1]) then
					ret = ret .. "* " .. key1 .. "-" .. key2 .. "=" .. form2 .. "(" .. (form1.nota or "") .. ")\n"
				end
			end
		elseif key1 ~= "nota" and not defectius[key1] then
			ret = ret .. "* " .. key1 .. "=" .. form1 .. "()\n"
		end
	end
	
	return ret
end

function p.make_table(forma, title, tipus_def)
	local defectius = formesDefectives(tipus_def)
	if #defectius > 0  then
		title = title .. ", defectiva"
	end
	
	-- Pronoms
	local pp_pro_ref = {'', '', '', '', '', ''}
	local pp_pro_el = {'', '', '', '', '', ''}
	local pp_pro_el_c = {'', '', '', '', '', ''}
	local pp_enc_ple = {'', '', '', '', '', ''}
	local pp_enc_red = {'', '', '', '', '', ''}
	local vpron = ''
	if pagename:find("[-']") then
		vpron = mw.ustring.gsub(pagename, ".-[-']", "", 1)
	end
	if vpron == "se" or vpron == "s" then
		vpron = "-se"
		pp_pro_ref = {"em ", "et ", "es ", "ens ", "us ", "es "}
		if forma.inf:find("^s") then
			pp_pro_ref[3] = "se "
			pp_pro_ref[6] = "se "
		end
		pp_pro_el = {"m'", "t'", "s'", "ens ", "us ", "s'"}
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-me", "-te", "-se", "-nos", "-vos", "-se"}
		pp_enc_red = {"'m", "'t", "'s", "'ns", "-us", "'s"}
	elseif vpron == "se'n" then
		vpron = "-se'n"
		pp_pro_ref = {"me'n ", "te'n ", "se'n ", "ens en ", "us en ", "se'n "}
		pp_pro_el = {"me n'", "te n'", "se n'", "ens n'", "us n'", "se n'"}
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-me'n", "-te'n", "-se'n", "-nos-en", "-vos-en", "-se'n"}
		pp_enc_red = {"-me'n", "-te'n", "-se'n", "'ns-en", "-us-en", "-se'n"}
	elseif vpron == "se-la" then
		vpron = "-se-la"
		pp_pro_ref = {"me la ", "te la ", "se la ", "ens la ", "us la ", "se la "}
		pp_pro_el_c = {"me l'", "te l'", "se l'", "ens l'", "us l'", "se l'"}
		if forma.inf:find("^h?[aeo]") then
			pp_pro_el = pp_pro_el_c
		else
			pp_pro_el = pp_pro_ref
		end
		pp_enc_ple = {"-me-la", "-te-la", "-se-la", "-nos-la", "-vos-la", "-se-la"}
		pp_enc_red = {"-me-la", "-te-la", "-se-la", "'ns-la", "-us-la", "-se-la"}
	elseif vpron == "se-les" then
		vpron = "-se-les"
		pp_pro_ref = {"me les ", "te les ", "se les ", "ens les ", "us les ", "se les "}
		pp_pro_el = pp_pro_ref
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-me-les", "-te-les", "-se-les", "-nos-les", "-vos-les", "-se-les"}
		pp_enc_red = {"-me-les", "-te-les", "-se-les", "'ns-les", "-us-les", "-se-les"}
	elseif vpron == "s'hi" then
		vpron = "-s'hi"
		pp_pro_ref = {"m'hi ", "t'hi ", "s'hi ", "ens hi ", "us hi ", "s'hi "}
		pp_pro_el = pp_pro_ref
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-m'hi", "-t'hi", "-s'hi", "-nos-hi", "-vos-hi", "-s'hi"}
		pp_enc_red = {"-m'hi", "-t'hi", "-s'hi", "'ns-hi", "-us-hi", "-s'hi"}
	elseif vpron == "ne" then
		vpron = "-ne"
		pp_pro_ref = {"en ", "en ", "en ", "en ", "en ", "en "}
		pp_pro_el = {"n'", "n'", "n'", "n'", "n'", "n'"}
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-ne", "-ne", "-ne", "-ne", "-ne", "-ne"}
		pp_enc_red = {"'n", "'n", "'n", "'n", "'n", "'n"}
	elseif vpron == "hi" then
		vpron = "-hi"
		pp_pro_ref = {"hi ", "hi ", "hi ", "hi ", "hi ", "hi "}
		pp_pro_el = pp_pro_ref
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-hi", "-hi", "-hi", "-hi", "-hi", "-hi"}
		pp_enc_red = pp_enc_ple
	elseif vpron == "la" then
		vpron = "-la"
		pp_pro_ref = {"la ", "la ", "la ", "la ", "la ", "la "}
		pp_pro_el_c = {"l'", "l'", "l'", "l'", "l'", "l'"}
		if forma.inf:find("^h?[aeo]") then
			pp_pro_el = pp_pro_el_c
		else
			pp_pro_el = pp_pro_ref
		end
		pp_enc_ple = {"-la", "-la", "-la", "-la", "-la", "-la"}
		pp_enc_red = pp_enc_ple
	elseif vpron == "les" then
		vpron = "-les"
		pp_pro_ref = {"les ", "les ", "les ", "les ", "les ", "les "}
		pp_pro_el = pp_pro_ref
		pp_pro_el_c = pp_pro_el
		pp_enc_ple = {"-les", "-les", "-les", "-les", "-les", "-les"}
		pp_enc_red = pp_enc_ple
	end
	
	local paradigmes = paradigma(forma, defectius, pp_pro_ref, pp_pro_el)
	
	-- Make links out of all forms
	for key1, form1 in pairs(forma) do
		if type(form1) == "table" then
			for key2, form2 in pairs(form1) do
				if type(form2) == "table" then
					for key3, form3 in pairs(form2) do
						if key3 ~= "nota" and form3 ~= '-' then
							if key1 == "ger" or key1 == "no-ger" then
								if defectius[key1] then
									forma[key1][key2][key3] = "<span style=\"color:#aaa\">" .. form3 .. pp_enc_ple[3] .. "</span>"
								else
									forma[key1][key2][key3] = "[[" .. form3 .. "]]" .. pp_enc_ple[3]
								end
							elseif key1 == "imp" or key1 == "no-imp" then
								if defectius[key3] or defectius[key1] then
									forma[key1][key2][key3] = "<span style=\"color:#aaa\">" .. form3 .. (form3:find("[aeio]$") and pp_enc_red[key3] or pp_enc_ple[key3]) .. "</span>"
								else
									forma[key1][key2][key3] = "[[" .. form3 .. "]]" .. (form3:find("[aeio]$") and pp_enc_red[key3] or pp_enc_ple[key3])
								end
							elseif key1 == "part" or key1 == "no-part" then
								if defectius[key3] or defectius[key1] then
									forma[key1][key2][key3] = "<span style=\"color:#aaa\">" .. form3 .. "</span>"
								else
									forma[key1][key2][key3] = "[[" .. form3 .. "]]"
								end
							else
								if defectius[key3] or defectius[key1] then
									forma[key1][key2][key3] = "<span style=\"color:#aaa\">" .. (form3:find("^[aeiouh]") and pp_pro_el[key3] or pp_pro_ref[key3]) .. form3 .. "</span>"
								else
									forma[key1][key2][key3] = (form3:find("^[aeiouh]") and pp_pro_el[key3] or pp_pro_ref[key3]) .. "[[" .. form3 .. "]]"
								end
							end
						end
					end
				elseif key2 ~= "nota" and form2 ~= '-' then
					if defectius[key2] or defectius[key1] then
						forma[key1][key2] = "<span style=\"color:#aaa\">" .. form2 .. "</span>"
					else
						forma[key1][key2] = "[[" .. form2 .. "]]"
					end
				end
			end
		elseif key1 == "no-ger" and form1 ~= '-' then
			if defectius[key1] then
				forma[key1] = "<span style=\"color:#aaa\">" .. form1 .. pp_enc_ple[3] .. "</span>"
			else
				forma[key1] = "[[" .. form1 .. "]]" .. pp_enc_ple[3]
			end
		end
	end
	
	local part = forma.part[1] and forma.part[1]["m-s"] or nil
	if #forma.part > 1 then
		if forma.part[2]["m-s"] ~= "[[nat]]" then
			part = part .. " o " .. forma.part[2]["m-s"]
		end
	end
	
	return makeSimples(forma, part, title, vpron) ..
		makeAlternatives(forma) ..
		makeCompostes(forma.inf, part, pp_pro_ref, pp_pro_el, pp_pro_el_c, defectius) ..
		paradigmes ..
		rizo(forma.rizo)
end

return p