İçeriğe atla

Modül:de-eylem

Vikisözlük sitesinden
Modül belgelemesi [Düzenle] [Tazele]


local export = {}

local data = {}

local m_table = require("Modül:de-eylem/tablo")

local irregular_verbs = {
	["brennen" ] = true,
	["bringen" ] = true,
	["dürfen"  ] = true,
	["fahren"  ] = true,
	["haben"   ] = true,
	["kommen"  ] = true,
	["können"  ] = true,
	["lassen"  ] = true,
	["mögen"   ] = true,
	["müssen"  ] = true,
	["schlafen"] = true,
	["schwören"] = true,
	["sein"    ] = true,
	["senden"  ] = true,
	["sollen"  ] = true,
	["stehen"  ] = true,
	["tun"     ] = true,
	["wenden"  ] = true,
	["werden"  ] = true,
	["wissen"  ] = true,
	["winnen"  ] = true,
	["wollen"  ] = true,
}

local pp = {
	["wollen"  ] = true,
}

local function append(stem,suffix)
	stem = mw.text.split(stem,"_",true)
	for i=1,#stem do
		stem[i] = stem[i] .. suffix
	end
	return #stem==1 and stem[1] or stem
end

local function make_pres_indc(conj,stem)
	local len = mw.ustring.len(stem)
	local final = mw.ustring.sub(stem,len,len)
	conj["inf"] = stem .. "en"
	conj["prp"] = stem .. "end"
	conj["1s_pres_indc"] = stem .. "e"
	conj["3s_pres_indc"] = stem .. "t"
	conj["1p_pres_indc"] = stem .. "en"
	conj["3p_pres_indc"] = stem .. "en"
	if final == "s" or final == "ß" then
		conj["2s_pres_indc"] = stem .. "t"
		conj["2p_pres_indc"] = stem .. "t"
		conj["2s_imp"] = {stem, stem .. "e"}
		conj["2p_imp"] = stem .. "t"
	elseif final == "t" then
		conj["2s_pres_indc"] = stem .. "est"
		conj["3s_pres_indc"] = stem .. "et"
		conj["2p_pres_indc"] = stem .. "et"
		conj["2s_imp"] = stem .. "e"
		conj["2p_imp"] = stem .. "t"
	elseif final == "d" then
		conj["2s_pres_indc"] = stem .. "est"
		conj["3s_pres_indc"] = stem .. "et"
		conj["2p_pres_indc"] = stem .. "et"
		conj["2s_imp"] = stem .. "e"
		conj["2p_imp"] = stem .. "t"
	else
		conj["2s_pres_indc"] = stem .. "st"
		conj["2p_pres_indc"] = stem .. "t"
		conj["2s_imp"] = {stem, stem .. "e"}
		conj["2p_imp"] = stem .. "t"
	end
end

local function make_pres_subj(conj,stem)
	conj["1s_pres_subj"] = stem .. "e"
	conj["2s_pres_subj"] = stem .. "est"
	conj["3s_pres_subj"] = stem .. "e"
	conj["1p_pres_subj"] = stem .. "en"
	conj["2p_pres_subj"] = stem .. "et"
	conj["3p_pres_subj"] = stem .. "en"
end

local function make_pres(conj,stem)
	make_pres_indc(conj,stem)
	make_pres_subj(conj,stem)
end

local function make_past_indc(conj,stem)
	local len = mw.ustring.len(stem)
	local final = mw.ustring.sub(stem,len,len)
	conj["1s_pret_indc"] = append(stem,"")
	conj["3s_pret_indc"] = append(stem,"")
	conj["1p_pret_indc"] = append(stem,"en")
	conj["3p_pret_indc"] = append(stem,"en")
	if final == "s" or final == "ß" then
		conj["2s_pret_indc"] = append(stem,"t")
		conj["2p_pret_indc"] = append(stem,"t")
	elseif final == "t" then
		conj["1s_pret_indc"] = append(stem,"e")
		conj["2s_pret_indc"] = append(stem,"est")
		conj["3s_pret_indc"] = append(stem,"e")
		conj["2p_pret_indc"] = append(stem,"et")
	elseif final == "d" then
		conj["2s_pret_indc"] = append(stem,"est")
		conj["2p_pret_indc"] = append(stem,"et")
	else
		conj["2s_pret_indc"] = append(stem,"st")
		conj["2p_pret_indc"] = append(stem,"t")
	end
end

local function make_past_subj(conj,stem)
	conj["1s_pret_subj"] = append(stem,"e")
	conj["2s_pret_subj"] = append(stem,"est")
	conj["3s_pret_subj"] = append(stem,"e")
	conj["1p_pret_subj"] = append(stem,"en")
	conj["2p_pret_subj"] = append(stem,"et")
	conj["3p_pret_subj"] = append(stem,"en")
end

local function make_past(conj,stem)
	make_past_indc(conj,stem)
	make_past_subj(conj,stem)
end

data["en"] = function(stem)
	local conj = {}
	conj["inf"] = stem .. "en"
	conj["prp"] = stem .. "end"
	conj["pp"] = stem .. "t"
	
	conj["1s_pres_indc"] = stem .. "e"
	conj["2s_pres_indc"] = stem .. "st"
	conj["3s_pres_indc"] = stem .. "t"
	conj["1p_pres_indc"] = stem .. "en"
	conj["2p_pres_indc"] = stem .. "t"
	conj["3p_pres_indc"] = stem .. "en"
	
	conj["1s_pres_subj"] = stem .. "e"
	conj["2s_pres_subj"] = stem .. "est"
	conj["3s_pres_subj"] = stem .. "e"
	conj["1p_pres_subj"] = stem .. "en"
	conj["2p_pres_subj"] = stem .. "et"
	conj["3p_pres_subj"] = stem .. "en"
	
	make_past(conj,stem.."t")

	conj["2s_imp"] = {stem, stem .. "e"}
	conj["2p_imp"] = stem .. "t"
	
	return conj
end

data["sen"] = function(stem)
	local conj = data["en"](stem .. "s")

	conj["2s_pres_indc"] = stem .. "st"

	return conj
end

data["ßen"] = function(stem)
	local conj = data["en"](stem .. "ß")

	conj["2s_pres_indc"] = stem .. "ßt"

	return conj
end

data["ten"] = function(stem)
	local conj = data["en"](stem .. "t")
	conj["pp"] = stem .. "tet"
	
	conj["2s_pres_indc"] = stem .. "test"
	conj["3s_pres_indc"] = stem .. "tet"
	conj["2p_pres_indc"] = stem .. "tet"
	
	make_past(conj,stem .. "tet")
	
	conj["2s_imp"] = stem .. "te"
	conj["2p_imp"] = stem .. "tet"
	
	return conj
end

data["den"] = function(stem)
	local conj = data["en"](stem .. "d")
	conj["pp"] = stem .. "det"
	
	conj["2s_pres_indc"] = stem .. "dest"
	conj["3s_pres_indc"] = stem .. "det"
	conj["2p_pres_indc"] = stem .. "det"

	make_past(conj,stem .. "det")
	
	conj["2s_imp"] = stem .. "de"
	conj["2p_imp"] = stem .. "det"
	
	return conj
end

data["echen"] = function(stem, consonant)
	local conj = data["en"](stem .. "ech")
	conj["pp"] = stem .. "ochen"
	
	conj["2s_pres_indc"] = stem .. "ichst"
	conj["3s_pres_indc"] = stem .. "icht"
	
	make_past_indc(conj, stem .. "ach")
	make_past_subj(conj, stem .. "äch")
	
	conj["2s_imp"] = stem .. "ich"
	
	return conj
end

data["ehmen"] = function(stem, consonant)
	local conj = data["en"](stem .. "ehm")
	conj["pp"] = stem .. "ommen"
	
	conj["2s_pres_indc"] = stem .. "immst"
	conj["3s_pres_indc"] = stem .. "immt"
	
	make_past_indc(conj, stem .. "ahm")
	make_past_subj(conj, stem .. "ähm")
	
	conj["2s_imp"] = stem .. "imm"
	
	return conj
end

data["ehen"] = function(stem)
	local conj = data["en"](stem .. "eh")
	conj["pp"] = stem .. "ehen"
	
	conj["2s_pres_indc"] = stem .. "iehst"
	conj["3s_pres_indc"] = stem .. "ieht"
	
	make_past_indc(conj, stem .. "ah")
	make_past_subj(conj, stem .. "äh")
	
	if stem == "sch" then
		conj["2s_imp"] = "schieh"
	else
		conj["2s_imp"] = {stem .. "ieh", stem .. "iehe"}
	end
	
	return conj
end

data["ennen"] = function(stem)
	local conj = data["en"](stem .. "enn")
	conj["pp"] = stem .. "annt"
	
	make_past_indc(conj, stem .. "annt")

	return conj
end

data["inden"] = function(stem)
	local conj = data["den"](stem .. "in")
	conj["pp"] = stem .. "unden"
	
	make_past_indc(conj, stem .. "and")
	make_past_subj(conj, stem .. "änd")
	
	return conj
end

data["ießen"] = function(stem)
	local conj = data["ßen"](stem .. "ie")
	conj["pp"] = stem .. "ossen"
	
	make_past_indc(conj, stem .. "oss")
	make_past_subj(conj, stem .. "öss")

	return conj
end

data["bringen"] = function(stem)
	local conj = data["en"]("bring")
	conj["pp"] = "bracht"
	
	make_past_indc(conj, "brach")
	make_past_subj(conj, "bräch")
	
	return conj
end

data["fahren"] = function(stem)
	local conj = data["en"]("fahr")
	conj["pp"] = "fahren"
	
	conj["2s_pres_indc"] = "fährst"
	conj["3s_pres_indc"] = "fährt"
	
	make_past_indc(conj,"fuhr")
	make_past_subj(conj,"führ")
	
	return conj
end

data["kommen"] = function(stem)
	local conj = data["en"]("komm")
	conj["pp"] = "kommen"
	
	make_past_indc(conj,"kam")
	make_past_subj(conj,"käm")
	
	return conj
end

data["lassen"] = function(stem)
	local conj = data["sen"]("las")
	conj["pp"] = "lassen"
	
	conj["2s_pres_indc"] = "lässt"
	conj["3s_pres_indc"] = "lässt"
	
	make_past(conj,"ließ")
	
	return conj
end

data["löschen"] = function(stem)
	local conj = data["en"]("lösch")
	conj["pp"] = "loschen"
	
	conj["2s_pres_indc"] = "lischst"
	conj["3s_pres_indc"] = "lischt"
	
	conj["2s_imp"] = {"lisch", "lische"}
	
	make_past_indc(conj,"losch")
	make_past_subj(conj,"lösch")
	
	return conj
end

data["schaffen"] = function(stem)
	local conj = data["en"]("schaff")
	conj["pp"] = "schaffen"
	
	make_past_indc(conj,"schuf")
	make_past_subj(conj,"schüf")
	
	return conj
end

data["schlafen"] = function(stem)
	local conj = data["en"]("schlaf")
	conj["pp"] = "schlafen"
	
	conj["2s_pres_indc"] = "schläfst"
	conj["3s_pres_indc"] = "schläft"
	
	make_past(conj,"schlief")
	
	return conj
end

data["schwören"] = function(stem)
	local conj = data["en"]("schwör")
	conj["pp"] = "schworen"
	
	make_past_indc(conj,"schwor_schwur")
	make_past_subj(conj,"schwör_schwür")
	
	return conj
end

data["sein"] = function(stem)
	local conj = {}
	conj["inf"] = "sein"
	conj["prp"] = "seiend"
	conj["pp"] = "wesen"
	
	conj["1s_pres_indc"] = "bin"
	conj["2s_pres_indc"] = "bist"
	conj["3s_pres_indc"] = "ist"
	conj["1p_pres_indc"] = "sind"
	conj["2p_pres_indc"] = "seid"
	conj["3p_pres_indc"] = "sind"
	
	conj["1s_pres_subj"] = "sei"
	conj["2s_pres_subj"] = "seist"
	conj["3s_pres_subj"] = "sei"
	conj["1p_pres_subj"] = "seien"
	conj["2p_pres_subj"] = "seiet"
	conj["3p_pres_subj"] = "seien"
	
	make_past_indc(conj, "war")
	make_past_subj(conj, "wär")

	conj["2s_imp"] = "sei"
	conj["2p_imp"] = "seid"
	
	return conj
end

data["stehen"] = function(stem)
	local conj = data["en"]("steh")
	conj["pp"] = "standen"
	
	make_pres_subj(conj, "ständ_stünd")
	make_past_indc(conj, stem .. "stand")
	
	return conj
end

data["tun"] = function(stem)
	local conj = data["en"]("tu")
	conj["inf"] = "tun"
	conj["prp"] = "tuend"
	conj["pp"] = "tan"
	
	conj["1p_pres_indc"] = "tun"
	conj["3p_pres_indc"] = "tun"
	
	make_past_indc(conj, "tat")
	conj["1s_pret_indc"] = "tat"
	conj["3s_pret_indc"] = "tat"
	
	make_past_subj(conj, "tät")
	
	return conj
end

data["thun"] = function(stem)
	local conj = data["en"]("thu")
	conj["inf"] = "thun"
	conj["prp"] = "thuend"
	conj["pp"] = "than"
	
	conj["1p_pres_indc"] = "thun"
	conj["3p_pres_indc"] = "thun"
	
	make_past_indc(conj, "that")
	conj["1s_pret_indc"] = "that"
	conj["3s_pret_indc"] = "that"
	
	make_past_subj(conj, "thät")
	
	return conj
end

data["winnen"] = function(stem)
	local conj = data["en"]("winn")
	conj["pp"] = "wonnen"
	
	make_past_indc(conj,"wann")
	make_past_subj(conj,"wänn")
	
	return conj
end

data["wollen"] = function(stem)
	local conj = data["en"]("woll")
	
	conj["1s_pres_indc"] = "will"
	conj["2s_pres_indc"] = "willst"
	conj["3s_pres_indc"] = "will"

	return conj
end

function export.auto(frame)
	args = frame:getParent().args
	local sep_prefix = args[1] or ""
	local insep_prefix = args[2] or ""
	local stem = args[3] or ""
	local conj_type = args[4] or ""
	local aux = args["aux"] or "h"
	local insep = args["insep"] or ""
	local impersonal = args["impersonal"] or args["imp"] or false
	
	sep_prefix = sep_prefix:gsub(" "," ")
	
	if conj_type == "" and stem == "" and insep_prefix == "" and sep_prefix == "" then -- {{de-conj-auto}}
		error("Please provide at least one argument")
	elseif conj_type == "" and stem == "" and insep_prefix == "" then -- {{de-conj-auto|sein}}
		conj_type = sep_prefix
		sep_prefix = ""
	elseif conj_type == "" and stem == "" then
		if irregular_verbs[insep_prefix] then -- {{de-conj-auto|ab|tun}}
			conj_type = insep_prefix
			insep_prefix = ""
		else -- {{de-conj-auto|mach|en}}
			conj_type = insep_prefix
			stem = sep_prefix
			insep_prefix = ""
			sep_prefix = ""
		end
	elseif conj_type == "" then
		if irregular_verbs[stem] then -- {{de-conj-auto|an|ver|tun}} (does not exist)
			conj_type = stem
			stem = ""
		else -- {{de-conj-auto|ab|f|inden}}
			conj_type = stem
			stem = insep_prefix
			insep_prefix = ""
		end
	end
	if insep ~= "" and insep ~= "no" and insep ~= "0" and insep_prefix == "" then
		insep_prefix = sep_prefix
		sep_prefix = ""
	end
	
	if not data[conj_type] then error("Conjugation type not recognized by module") end
	conj = data[conj_type](stem)
	
	if pp[conj_type] then
		conj["2s_imp"] = nil
		conj["2p_imp"] = nil
	end
	
	text = m_table.maketable(sep_prefix,insep_prefix,conj,aux,impersonal)
	return text
end

function export.stems(frame)
	args = frame:getParent().args
	local sep_prefix = args[1] or ""
	local stems = args[2] or ""
	local pp = args[3] or ""
	local aux = args["aux"] or "h"
	local impersonal = args["impersonal"] or ""
	if impersonal == "" then impersonal = args["imp"] or "" end
	if impersonal == "" then impersonal = false end
	
	sep_prefix = sep_prefix:gsub(" "," ")
	
	if sep_prefix == "" and stems == "" and pp == "" then -- {{de-conj-stems}}
		error("Please provide at least one argument")
	elseif stems == "" then -- {{de-conj-stems|abandonnier}}
		stems = sep_prefix
		sep_prefix = ""
	elseif pp == "" then
		if mw.ustring.match(sep_prefix,"/") then
			pp = stems
			stems = sep_prefix
			sep_prefix = ""
		end
	end
	
	local conj = {}
	
	stems = mw.text.split(stems,"/")
	if pp == "" then
		conj["pp"] = "ge" .. stems[1] .. "t"
	else
		conj["pp"] = pp
	end
	
	if #stems == 1 then
		make_pres(conj,stems[1])
		make_past(conj,stems[1])
	elseif #stems == 2 then
		make_pres(conj,stems[1])
		make_past(conj,stems[2])
	elseif #stems == 3 then
		make_pres(conj,stems[1])
		make_past_indc(conj,stems[2])
		make_past_subj(conj,stems[3])
	elseif #stems == 4 then
		make_pres_indc(conj,stems[1])
		make_pres_subj(conj,stems[2])
		make_past_indc(conj,stems[3])
		make_past_subj(conj,stems[4])
	end
	
	if args["pp"] then
		conj["2s_imp"] = nil
		conj["2p_imp"] = nil
	end
	
	text = m_table.maketable(sep_prefix,"",conj,aux,impersonal,true)
	return text
end

return export