Modulo:La-paradigma

Questo modulo costituisce il codice di funzionamento del Template:La-paradigma e crea, in base ai parametri inseriti in quest'ultimo, lo specchietto del paradigma dei verbi latini.

Il suo codice è fondamentalmente una versione semplificata di quello del Modulo:La-conj, e ne condivide il funzionamento essenziale (anche se ovviamente restituisce solo le voci del paradigma invece che la tabella)


-- Questo modulo contiene il codice per il template:la-paradigma, che genera il paradigma coniugazione di tutti i verbi latini
-- La funzione lapara genera le voci verbali del paradigma in base ai parametri passati dal template

p = {}

function p.lapara(frame)
	pframe = frame:getParent()
	config = frame.args
	args = pframe.args
-- Argomenti passati dal template
	tipo = config["tipo"] or " "
	coniug = config["coniug"]
	temapres = config["temapres"]
	if tipo == "dep" or tipo == "semidep" then --toglie di mezzo il tema del perfetto per deponenti e semideponenti
		temaperf = "n.e."
	else
		temaperf = config["temaperf"]
	end
	temasup = config["temasup"]
	impersonale = config["impersonale"] or nil
	if frame.args["temainf"] > "0" then temainf = config["temainf"] else temainf = temapres end --nel 99% dei casi il tema dell'infinito è uguale a quello del presente, risparmiamo un parametro
	para = config["para"] or " " --questa serve per il template:La-paradigma
-- Inizializzazione di tutte le variabili interne, che potrebbero altrimenti risultare nulle
	paradigma = ""; descrizione = ""; coniug_descr = ""; tipo_descr = ""
	pres1s = ""; pres2s = ""; perf1s = ""; sup = ""; infpres = ""
	difettivo = ""; difettivo_descr = ""; difettivopres = ""; difettivoperf = ""; difettivosup = ""; difettivoconj = ""
	
-- A partire dalla coniugazione, genera le forme coniugate standard per ciascuna tipologia di verbo
	if (coniug == "1") then --PRIMA CONIUGAZIONE
		pres1s = p.wiki(temapres .. "ō"); pres2s = p.wiki(temapres .. "ās"); pres3s = p.wiki(temapres .. "at"); perf1s = p.wiki(temaperf .. "ī"); perf3s = p.wiki(temaperf .. "it"); sup = p.wiki(temasup .. "um"); infpres = p.wiki(temainf .. "āre")
		pass_pres1s = p.wiki(temapres .. "or"); pass_pres2s = p.wiki(temapres .. "āris"); pass_pres3s = p.wiki(temapres .. "ātur"); pass_perf1s = p.wiki(temasup .. "us").. " [[sum#Latino|sum]]"; pass_perf3s = p.wiki(temasup .. "us").. " [[est#Latino|est]]"; pass_infpres = p.wiki(temainf .. "ari")
	elseif (coniug == "2") then --SECONDA CONIUGAZIONE
		pres1s = p.wiki(temapres .. "ĕo"); pres2s = p.wiki(temapres .. "es"); pres3s = p.wiki(temapres .. "et"); perf1s = p.wiki(temaperf .. "i"); perf3s = p.wiki(temaperf .. "it"); sup = p.wiki(temasup .. "um"); infpres = p.wiki(temainf .. "ēre")
		pass_pres1s = p.wiki(temapres .. "ĕor"); pass_pres2s = p.wiki(temapres .. "ēris"); pass_pres3s = p.wiki(temapres .. "ētur"); pass_perf1s = p.wiki(temasup .. "us").. " [[sum#Latino|sum]]"; pass_perf3s = p.wiki(temasup .. "us").. " [[est#Latino|est]]"; pass_infpres = p.wiki(temainf .. "ēri")
	elseif (coniug == "3") then --TERZA CONIUGAZIONE
		pres1s = p.wiki(temapres .. "ō"); pres2s = p.wiki(temapres .. "is"); pres3s = p.wiki(temapres .. "it"); perf1s = p.wiki(temaperf .. "i"); perf3s = p.wiki(temaperf .. "it"); sup = p.wiki(temasup .. "um"); infpres = p.wiki(temainf .. "ĕre")
		pass_pres1s = p.wiki(temapres .. "or"); pass_pres2s = p.wiki(temapres .. "ĕris"); pass_perf1s = p.wiki(temasup .. "us").. " [[sum#Latino|sum]]"; pass_infpres = p.wiki(temainf .. "i")
	elseif (coniug == "3-io") then --TERZA CONIUGAZIONE, VARIANTE IN -IO
		pres1s = p.wiki(temapres .. "iō"); pres2s = p.wiki(temapres .. "is"); pres3s = p.wiki(temapres .. "it"); perf1s = p.wiki(temaperf .. "i"); perf3s = p.wiki(temaperf .. "it"); sup = p.wiki(temasup .. "um"); infpres = p.wiki(temainf .. "ĕre")
		pass_pres1s = p.wiki(temapres .. "ior"); pass_pres2s = p.wiki(temapres .. "ĕris"); pass_perf1s = p.wiki(temasup .. "us").. " [[sum#Latino|sum]]"; pass_infpres = p.wiki(temainf .. "i")
	elseif (coniug == "4") then --QUARTA CONIUGAZIONE
		pres1s = p.wiki(temapres .. "iō"); pres2s = p.wiki(temapres .. "īs"); pres3s = p.wiki(temapres .. "it"); perf1s = p.wiki(temaperf .. "ī"); perf3s = p.wiki(temaperf .. "it"); sup = p.wiki(temasup .. "um"); infpres = p.wiki(temainf .. "īre")
		pass_pres1s = p.wiki(temapres .. "ior"); pass_pres2s = p.wiki(temapres .. "īris"); pass_perf1s = p.wiki(temasup .. "us").. " [[sum#Latino|sum]]"; pass_infpres = p.wiki(temainf .. "iri")
	elseif (coniug == "sum") then --IRREGOLARE, SUM, ES, FUI, ESSE
		if temapres < "a" or temaperf < "a" then
			temapres_s = "s"; temapres_e = "e"; temaperf = "f"; temainf = "e"
		else
			temapres_s = temapres.. "s"; temapres_e = temapres.. "e"; temaperf = temaperf.. "f"; temainf = temainf.. "e"
		end
		pres1s = p.wiki(temapres_s .. "um"); pres2s = p.wiki(temapres_e .. "s"); pres3s = p.wiki(temapres_e .. "st"); perf1s = p.wiki(temaperf .. "ui"); perf3s = p.wiki(temaperf .. "uit"); sup = "" infpres = p.wiki(temainf .. "sse")
	elseif (coniug == "fero") then --IRREGOLARE FERO, FERS, TULI, LATUM, FERRE
		pres1s = p.wiki(temapres .. "ferō"); pres2s = p.wiki(temapres .. "fers"); perf1s = p.wiki(temaperf .. "tulī"); sup = p.wiki(temasup .. "lātum"); infpres = p.wiki(temapres .. "ferre")
	elseif (coniug == "inquam") then --IRREGOLARE DIFFETIVO, INQUAM
		pres1s = p.wiki(temapres .. "am"); pres2s = p.wiki(temapres .. "is"); perf1s = p.wiki(temaperf .. "ī"); sup = "n.e."; infpres = "n.e."
	end
	
--in base al parametro "tipo" (passato dal template), definisce cosa succede se il verbo è deponente, semideponente o privo di passivo
	if tipo >="a" and tipo == "dep" then --se il verbo è deponente, le voci attive combaciano con quelle passive:
		pres1s = pass_pres1s; pres2s = pass_pres2s; pres3s = pass_pres3s; perf1s = pass_perf1s; perf3s = pass_perf3s; infpres = pass_infpres
	elseif tipo >="a" and tipo == "semidep" then --se il verbo è semideponente, le sole voci attive derivate dal perfetto combaciano con quelle passive:
		perf1s = pass_perf1s; perf3s = pass_perf3s
	end

-- Recupera le eventuali forme irregolari o varianti, rimpiazziandole o aggiungendole a quelle standard
	pres1s2 = p.wiki(args["pres1s2"]); pres2s2 = p.wiki(args["pres2s2"]); perf1s2 = p.wiki(args["perf1s2"]); sup2 = p.wiki(args["sup2"]); infpres2 = p.wiki(args["pres2"])
	pres1s = p.over(pres1s,args["pres1s"]); pres2s = p.over(pres2s,args["pres2s"]); perf1s = p.over(perf1s,args["perf1s"]); sup = p.over(sup,args["sup"]); infpres = p.over(infpres,args["infpres"])
	pass_pres1s = p.over(pres1s,args["pres1s"]); pass_pres2s = p.over(pres2s,args["pres2s"]); pass_perf1s = p.over(perf1s,args["perf1s"]); p_perf = p.over(p_perf,args["p_perf"]); pass_infpres = p.over(infpres,args["infpres"])
	pres1s = p.alts(pres1s,pres1s2); pres2s = p.alts(pres2s,pres2s2); perf1s = p.alts(perf1s,perf1s2); sup = p.alts(sup,sup2); infpres = p.alts(infpres,infpres2)
-- costruisce la stringa variabili "coniug_descr", che realizza la descrizione e la categoria per quanto riguarda la coniugazione verbale
	--costruisce il "coniug_descr" in base al parametro "coniug"
	if coniug == "1" then
		coniug_descr = "prima coniugazione" .. "[[Categoria:Verbi di prima coniugazione in latino]]"
	elseif coniug == "2" then
		coniug_descr = "seconda coniugazione" .. "[[Categoria:Verbi di seconda coniugazione in latino]]"
	elseif coniug == "3" then
		coniug_descr = "terza coniugazione" .. "[[Categoria:Verbi di terza coniugazione in latino]]"
	elseif coniug == "3-io" then
		coniug_descr = "terza coniugazione in -io" .. "[[Categoria:Verbi di terza coniugazione in latino]]"
	elseif coniug == "4" then
		coniug_descr = "quarta coniugazione" .. "[[Categoria:Verbi di quarta coniugazione in latino]]"
	elseif coniug == "sum" then
		coniug_descr = "irregolare" .. "[[Categoria:Verbi irregolari in latino]]"
	elseif coniug == "fero" then
		coniug_descr = "terza coniugazione irregolare, suppletivo" .. "[[Categoria:Verbi di terza coniugazione in latino]]".. "[[Categoria:Verbi irregolari in latino]]"
	elseif coniug == "inquam" then
		coniug_descr = "irregolare" .. "[[Categoria:Verbi irregolari in latino]]"
	end
	--costruisce il "tipo_descr" in base al parametro "tipo"; per deponenti e semideponenti aggiunge anche la relativa categoria
	if tipo == "dep" then
		tipo_descr = ", deponente[[Categoria:Verbi deponenti in latino]]"
	elseif tipo == "semidep" then
		tipo_descr = ", semideponente[[Categoria:Verbi semideponenti in latino]]"
	elseif tipo == "nopass" then
		tipo_descr = ", privo della forma passiva"
	else tipo_descr = ""
	end
	
--per i verbi difettivi, se il tema è nullo annulla anche tutte le forme derivate da esso, restituendole come "n.e." (PER I VERBI REGOLARI)
	if coniug == "1" or coniug == "2" or coniug == "3" or coniug == "3-io" or coniug == "4" then
		if temapres < "a" then --se il tema del presente è nullo, annulla le due voci verbali del presente
			difettivo = true; pres1s = "n.e.";  pres2s = "n.e."
		end
		if temaperf < "a" then --se il tema del perfetto è nullo, annulla la prima persona singolare dell'indicativo perfetto
			difettivo = true; perf1s = "n.e."
		end
		if temasup < "a" then --se il tema del perfetto è nullo, annulla il supino e il perfetto passivo
			difettivo = true; sup = "n.e."; pass_perf1s = "n.e."
		end
	elseif coniug == "sum" then --per SUM, ES, FUI, ESSE
		sup = "n.e."
	end
	
-- costruisce la stringa "difettivo" e "difettivo_descr", che specifica se il verbo e difettivo e dove (PER I VERBI REGOLARI)
	if coniug == "1" or coniug == "2" or coniug == "3" or coniug == "3-io" or coniug == "4" then
		if difettivo == true  then
			difettivo = "; ''difettivo''"; difettivoconj = "[[Categoria:Verbi difettivi in latino]]"
				if temapres < "a" then
					difettivopres = ", ''manca del tema del presente''"
				end
				if temaperf < "a" then
					difettivoperf = ", ''manca del tema del perfetto''"
				end
				if temasup < "a" then
					difettivosup = ", ''manca del tema del supino''"
				end
		end
	elseif coniug == "sum" then --per SUM, ES, FUI, ESSE, che manca del supino
		difettivo = "; ''difettivo'', ''manca del tema del supino''"; difettivoconj = "[[Categoria:Verbi difettivi in latino]]"
	elseif coniug == "inquam" then --per INQUAM
		difettivo = "; ''difettivo'', ''manca del tema del supino, dell'infinito e di numerose uscite''"; difettivoconj = "[[Categoria:Verbi difettivi in latino]]"
	end
	difettivo_descr = difettivopres.. difettivoperf.. difettivosup.. difettivoconj

--assembla tutte le variabili nell'unica stringa "paradigma"
	paradigma = coniug_descr.. tipo_descr.. " ([[paradigma]]: '''".. pres1s.. "''', '''".. pres2s.. "''', '''".. perf1s.. "''', '''".. sup.. "''', '''".. infpres.. "'''".. difettivo.. difettivo_descr.. ")"

--VERBI IMPERSONALI	
	if impersonale == "si" then
		paradigma = coniug_descr.. ", impersonale[[Categoria:Verbi impersonali in latino]]".. tipo_descr.. " ([[paradigma]]: '''".. pres3s.. "''', '''".. perf3s.. "''', '''".. sup.. "''', '''".. infpres.. "'''".. difettivo.. difettivo_descr.. ")"
	end
	if impersonale == "passivo" then
		paradigma = coniug_descr.. ", impersonale al passivo[[Categoria:Verbi impersonali al passivo in latino]]" .. tipo_descr.. " ([[paradigma]]: '''".. pres1s.. "''', '''".. pres2s.. "''', '''".. perf1s.. "''', '''".. sup.. "''', '''".. infpres.. "'''".. difettivo.. difettivo_descr.. ")"
	end
	
--restituisce il paradigma come output
	return paradigma
end

function p.nodiacritic(x)
-- funzione che rimuove gli eventuali accenti lunghi e brevi dalla radice (stem); in pratica se si scrive 'puĕr' restituisce 'puer'
	local dp={
	['ā']='a',['ă']='a',
	['ē']='e',['ĕ']='e',
	['ī']='i',['ĭ']='i',
	['ō']='o',['ŏ']='o',
	['ū']='u',['ŭ']='u',
	};
	return (mw.ustring.gsub(x, '.', dp))
end

function p.over(x,over)
-- Utilizzato all'interno della funzione itconj
-- Rimpiazza una voce verbale standard con quella eventualmente indicata nel template (se quest'ultimo è un link rosso, aggiunge anche la relativa categoria)
    if over == nil then return x end
    if over < "a" then return 'n.e.' end
	if over >= "a" then
		local over2 = p.nodiacritic(over)
		return "[[" .. over2 .. "#Latino|" .. over .. "]]"
	else 
		return "n.e."
	end
end

function p.alts(x,y)
-- Utilizzato all'interno della funzione laconj
-- Aggiunge le eventuali forme alternative, se specificate nel template, separandole da quelle base con una virgola
	if y == nil then return x end
	if y >= "0" then return x .. "/" .. y end
	return x
end

function p.wiki(x)
-- Utilizzato all'interno della funzione laconj
    if x == nil then return " " end
    if x == "" then return " " end
    	if 	x >= "a" then 
    		local y = p.nodiacritic(x) 
       		-- Rende il suo argomento un wikilink, restituendo ad es. "[[laudo#Latino|lăudō]], o lo rende nullo se non definito (per facilitare la concatenazione)
		if y == mw.title.getCurrentTitle().text then return x 
		else return "[[" .. y .. "#Latino|" .. x .. "]]" end
		else
		return " "
		end
	end
	
return p