Modul:Adjektiv

Aus KGS-Wiki

Die Dokumentation für dieses Modul kann unter Modul:Adjektiv/Doku erstellt werden

local p = {}
utils = require('Modul:LateinUtils')

local KASUS  = {'Nominativ', 'Genitiv', 'Dativ', 'Akkusativ', 'Ablativ', 'Vokativ'}
local NUMERI = {S = 'Singular', P = 'Plural'}
local NABBRV = {S = 'Sg.', P = 'Pl.'}
local STUFEN = {p = "[[Positiv (Steigerungsform|]]", k = "[[Komparativ]]", s = "[[Superlativ]]"}
local GENERA = {m = 'maskulinum', f = 'femininum', n = 'neutrum'}
local DEKLS = {
	o = {
		m = {
			S = {'', 'i', 'o', 'um', 'o', 'e'};
			P = {'i', 'orum', 'is', 'os', 'is'}
		};
		f = {
			S = {'', 'ae', 'ae', 'am', 'ā'};
			P = {'ae', 'arum', 'is', 'as', 'is'}
		};
		n = {
			S = {'', 'i', 'o', 'um', 'o'};
			P = {'a', 'orum', 'is', 'a', 'is'}
		};
		name = 'o-/a-Deklination'
	};
	i = {
		m = {
			S = {'', 'is', 'i', 'em', 'i'};
			P = {'es', 'ium', 'ibus', 'es', 'ibus'}
		};
		f = {
			S = {'', 'is', 'i', 'em', 'i'};
			P = {'es', 'ium', 'ibus', 'es', 'ibus'}
		};
		n = {
			S = {'', 'is', 'i', 'em', 'i'};
			P = {'ia', 'ium', 'ibus', 'ia', 'ibus'}
		};
		name = '3. Deklination'
	}
}

function bilde(m,f,n,stamm,dekl)
	formen = {S = {}, P = {}}
	for k=1,5 do
		formen['S'][k] = {m = stamm .. DEKLS[dekl]['m']['S'][k], f = stamm .. DEKLS[dekl]['f']['S'][k], n = stamm .. DEKLS[dekl]['n']['S'][k]}
		formen['P'][k] = {m = stamm .. DEKLS[dekl]['m']['P'][k], f = stamm .. DEKLS[dekl]['f']['P'][k], n = stamm .. DEKLS[dekl]['n']['P'][k]}
	end
	formen['S'][1] = {m = m, f = f, n = n}
	if dekl == 'o' then
		formen['S'][6] = {m = stamm .. 'e'}
	end
	formen['S'][4]['n'] = n
	return formen
end

function render(formen,dekl, stufe)
	local table = ''
	table = table .. '{| class="wikitable mw-collapsible"\n'
	-- LOTS AND LOTS OF WORK TO DO
	table = table .. '|+ ' .. STUFEN[stufe] .. '\n'
	for nk,nv in pairs(NUMERI) do
		table = table .. '|-\n'
	    table = table .. '! colspan="4" | [[' .. nv .. ']]\n'
	    table = table .. '|-\n'
	    table = table .. '! !! [[maskulinum]] !! [[femininum]] !! [[neutrum]]\n'
	    for kk,kv in pairs(formen[nk]) do
	    	table = table .. '|-\n'
	    	table = table .. '! [[' .. KASUS[kk] .. ']]\n'
	    	table = table .. ' || ' .. utils.enclose(kv['m'])
	                	  .. ' || ' .. utils.enclose(kv['f'])
	                 	  .. ' || ' .. utils.enclose(kv['n'])
                          .. '\n'
    	end
    end
	table = table .. '|}'
	return table
end

function p.render() 
	local frame = mw.getCurrentFrame()
    local baseM = frame.args[1] or frame:getParent().args[1] or 'acer'
    local baseF = frame.args[2] or frame:getParent().args[2] or 'acris'
    local baseN = frame.args[3] or frame:getParent().args[3] or 'acre'
    local posiS = frame.args[4] or frame:getParent().args[4] or 'acr'
    local dekl  = frame.args[5] or frame:getParent().args[5] or 'k'
    local lekt  = frame.args[6] or frame:getParent().args[6] or 32
    local kompS = frame.komp    or frame:getParent().komp    or posiS
    local superS= frame.superl  or frame:getParent().superl  or (posiS .. 'iss')
    local positiv = bilde(baseM, baseF, baseN, posiS, dekl)
    local komparativ = bilde(kompS .. 'ior', kompS .. 'ior', kompS .. 'ius', kompS, 'k')
    --local superlativ = bilde(superS .. 'imus', superS .. 'ima', superS .. 'imum', superS, 'o')
	local pagecontent = ''
	if not mw.isSubsting() then
    	pagecontent = pagecontent .. utils.renderTemplate("Achtung", {"Dieses Modul sollte nur mit <code>{{subst:#invoke:Adjektiv|...}}</code> eingebunden werden! "})
    end
    pagecontent = pagecontent .. "{{DISPLAYTITLE:" .. baseM .. "}}\n"
    pagecontent = pagecontent .. utils.renderTemplate("Thumbnailbox", {INHALT= utils.renderTemplate("Wortwolke", {basicM})}) .. "\n"
    pagecontent = pagecontent .. ";[[Lernformen]]: " .. utils.enclose(baseM) .. ", " .. utils.enclose(baseF) .. ", " .. utils.enclose(baseN) .. utils.renderTemplate("Link Campus-Lektion", {lekt})
    pagecontent = pagecontent .. '\n\n'
    pagecontent = pagecontent .. ";Bedeutungen\n\n"
    pagecontent = pagecontent .. ";Feste Wendungen\n\n"
    pagecontent = pagecontent .. ";Aufbau\n\n"
    pagecontent = pagecontent .. ";Verwandte Wörter\n\n"
    pagecontent = pagecontent .. ";In anderen Sprachen\n\n"
    pagecontent = pagecontent .. "== Formen ==\n\n"
    pagecontent = pagecontent .. render(positiv, dekl, 'p')
    --pagecontent = pagecontent .. render(komparativ, 'k', 'k')
    --pagecontent = pagecontent .. render(superlativ, 'o', 's')
    pagecontent = pagecontent .. '\n\n'
    pagecontent = pagecontent .. '== Weblinks ==\n\n'
    pagecontent = pagecontent .. '* ' .. utils.renderTemplate('Navigium', {baseM}) .. '\n'
    pagecontent = pagecontent .. '* ' .. utils.renderTemplate('Georges', {baseM}) .. '\n'
    pagecontent = pagecontent .. '[[Kategorie:Substantiv (Latein)/' .. baseM:sub(1,1) .. ']]\n'
    pagecontent = pagecontent .. utils.addCampusCategoryIfSet(lekt)
	return pagecontent
end

return p