এই মডিউলের জন্য মডিউল:odt-conj/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

local m_links = require("Module:links")
local m_utils = require("Module:utilities")

local lang = require("Module:languages").getByCode("odt")

local conj_data = {}

--[=[conj_data["pp"] = {
	params = {
		[1] = {},
		[2] = {},
		[3] = {},
		[4] = {},
		["pres2sg"] = {},
		["pastpart"] = {},
		["pastpart2"] = {},
		},
}
setmetatable(conj_data["pp"], {__call = function(self, args, data)
	data.conj_type = "[[preterite-present verb|preterite-present]]"
	
	data.forms["inf"] = {args.head or (args[2] .. "an")}
	
	data.forms["pres_ind_1s"] = {args[1]}
	data.forms["pres_ind_2s"] = {args["pres2sg"] or (args[1] .. "t")}
	data.forms["pres_ind_3s"] = {args[1]}
	data.forms["pres_ind_p"] = {args[2] .. "un"}

	data.forms["past_ind_1s"] = {args[3] .. "a"}
	data.forms["past_ind_2s"] = {args[3] .. "es"}
	data.forms["past_ind_3s"] = {args[3] .. "a"}
	data.forms["past_ind_p"] = {args[3] .. "un"}
		
	data.forms["pres_sub_1s"] = {args[2] .. "i"}
	data.forms["pres_sub_2s"] = {args[2] .. "is"}
	data.forms["pres_sub_3s"] = {args[2] .. "i"}
	data.forms["pres_sub_p"] = {args[2] .. "in"}
		
	data.forms["past_sub_1s"] = {args[3] .. "i"}
	data.forms["past_sub_2s"] = {args[3] .. "is"}
	data.forms["past_sub_3s"] = {args[3] .. "i"}
	data.forms["past_sub_p"] = {args[3] .. "in"}
	
	data.forms["pres_part"] = {args[2] .. "andi"}
	data.forms["past_part"] = args.pastpart and {args.pastpart, (args.pastpart2 and args.pastpart2)} or (args[4] and {"gi" .. args[4], args[4]} or {"—"})
	
	table.insert(data.categories, "Old Saxon preterite-present verbs")
end
})]=]

conj_data["st"] = {
	params = {
		[1] = {},
		[2] = {},
		[3] = {},
		[4] = {},
		["mutstem"] = {},
		["mutstem2"] = {},
		["impr"] = {},
		["class"] = {},
		},
}
setmetatable(conj_data["st"], {__call = function(self, args, data)
	if not args.class then
		error("Class parameter required for strong verbs")
	end
	data.conj_type = "strong class " .. args.class
	
	if args[1]:sub(1,1) == "*" then
		error("Redundant asterisks")
	end
	
	data.forms["inf"] = {args.head or (args[1] .. "an")}
	
	data.forms["pres_ind_1s"] = {args[1] .. "u"}
	data.forms["pres_ind_2s"] = {(args.mutstem or args[1]) .. "is", (args.mutstem or args[1]) .. "ist"}
	data.forms["pres_ind_3s"] = {(args.mutstem or args[1]) .. "it"}
	data.forms["pres_ind_1p"] = {args[1] .. "on"}
	data.forms["pres_ind_2p"] = {args[1] .. "et"}
	data.forms["pres_ind_3p"] = {args[1] .. "unt"}

	data.forms["past_ind_1s"] = {args[2]}
	data.forms["past_ind_2s"] = {args[3] .. "i"}
	data.forms["past_ind_3s"] = {args[2]}
	data.forms["past_ind_1p"] = {args[3] .. "un"}
	data.forms["past_ind_2p"] = {args[3] .. "ut"}
	data.forms["past_ind_3p"] = {args[3] .. "un"}

	data.forms["pres_sub_1s"] = {args[1] .. "e"}
	data.forms["pres_sub_2s"] = {args[1] .. "es", args[1] .. "est"}
	data.forms["pres_sub_3s"] = {args[1] .. "e"}
	data.forms["pres_sub_1p"] = {args[1] .. "en"}
	data.forms["pres_sub_2p"] = {args[1] .. "et"}
	data.forms["pres_sub_3p"] = {args[1] .. "ent"}
	
	data.forms["past_sub_1s"] = {args[3] .. "i"}
	data.forms["past_sub_2s"] = {args[3] .. "is", args[3] .. "ist"}
	data.forms["past_sub_3s"] = {args[3] .. "i"}
	data.forms["past_sub_1p"] = {args[3] .. "in"}
	data.forms["past_sub_2p"] = {args[3] .. "it"}
	data.forms["past_sub_3p"] = {args[3] .. "int"}
	
	data.forms["imp_s"] = {(args.impr or args.mutstem2) or args[1]}
	data.forms["imp_p"] = {args[1] .. "et"}
	
	data.forms["pres_part"] = {args[1] .. "andi"}
	data.forms["past_part"] = {"ge" .. args[4] .. "on"}
	
	table.insert(data.categories, "Old Dutch class " .. args.class .. " strong verbs")
end
})

conj_data.irregular = {}

conj_data.irregular["bringan"] = function(data)
	data.conj_type = "weak [[irregular]]"
	
	data.forms["inf"] = {"bringan"}
	
	data.forms["pres_ind_1s"] = {"bringu"}
	data.forms["pres_ind_2s"] = {"bringis", "bringist"}
	data.forms["pres_ind_3s"] = {"bringit"}
	data.forms["pres_ind_1p"] = {"bringon"}
	data.forms["pres_ind_2p"] = {"bringet"}
	data.forms["pres_ind_3p"] = {"bringunt"}

	data.forms["past_ind_1s"] = {"braht"}
	data.forms["past_ind_2s"] = {"brāhti"}
	data.forms["past_ind_3s"] = {"braht"}
	data.forms["past_ind_1p"] = {"brāhtun"}
	data.forms["past_ind_2p"] = {"brāhtut"}
	data.forms["past_ind_3p"] = {"brāhtun"}
	
	data.forms["pres_sub_1s"] = {"bringe"}
	data.forms["pres_sub_2s"] = {"bringes", "bringest"}
	data.forms["pres_sub_3s"] = {"bringe"}
	data.forms["pres_sub_1p"] = {"bringen"}
	data.forms["pres_sub_2p"] = {"bringet"}
	data.forms["pres_sub_3p"] = {"bringent"}

	data.forms["past_sub_1s"] = {"brāhti"}
	data.forms["past_sub_2s"] = {"brāhtis", "brāhtist"}
	data.forms["past_sub_3s"] = {"brāhti"}
	data.forms["past_sub_1p"] = {"brāhtin"}
	data.forms["past_sub_2p"] = {"brāhtit"}
	data.forms["past_sub_3p"] = {"brāhtint"}
	
	data.forms["imp_s"] = {"bring"}
	data.forms["imp_p"] = {"bringet"}
	
	data.forms["pres_part"] = {"bringandi"}
	data.forms["past_part"] = {"gebraht"}
	
	table.insert(data.categories, "Old Dutch weak verbs")
end

conj_data.irregular["gān"] = function(data)
	data.conj_type = "irregular, [[suppletive]]"
	
	data.forms["inf"] = {"gān"}
	
	data.forms["pres_ind_1s"] = {"gā"}
	data.forms["pres_ind_2s"] = {"gest"}
	data.forms["pres_ind_3s"] = {"get"}
	data.forms["pres_ind_1p"] = {"gān"}
	data.forms["pres_ind_2p"] = {"gāt"}
	data.forms["pres_ind_3p"] = {"gānt"}

	data.forms["past_ind_1s"] = {"geng"}
	data.forms["past_ind_2s"] = {"gengi"}
	data.forms["past_ind_3s"] = {"geng"}
	data.forms["past_ind_1p"] = {"gengun"}
	data.forms["past_ind_2p"] = {"gengut"}
	data.forms["past_ind_3p"] = {"gengun"}
	
	data.forms["pres_sub_1s"] = {"gā"}
	data.forms["pres_sub_2s"] = {"gās", "gāst"}
	data.forms["pres_sub_3s"] = {"gā"}
	data.forms["pres_sub_1p"] = {"gān"}
	data.forms["pres_sub_2p"] = {"gāt"}
	data.forms["pres_sub_3p"] = {"gān"}

	data.forms["past_sub_1s"] = {"gengi"}
	data.forms["past_sub_2s"] = {"gengis", "gengist"}
	data.forms["past_sub_3s"] = {"gengi"}
	data.forms["past_sub_1p"] = {"gengin"}
	data.forms["past_sub_2p"] = {"gengit"}
	data.forms["past_sub_3p"] = {"gengin"}
	
	data.forms["imp_s"] = {"gā"}
	data.forms["imp_p"] = {"gāt"}
	
	data.forms["pres_part"] = {"gangandi"}
	data.forms["past_part"] = {"gegangon"}
	
	table.insert(data.categories, "Old Dutch suppletive verbs")
end

conj_data.irregular["wesan"] = function(data)
	data.conj_type = "irregular, [[suppletive]]"
	
	data.forms["inf"] = {"wesan"}
	
	data.forms["pres_ind_1s"] = {"bim"}
	data.forms["pres_ind_2s"] = {"bis", "bist"}
	data.forms["pres_ind_3s"] = {"ist"}
	data.forms["pres_ind_1p"] = {"sīn"}
	data.forms["pres_ind_2p"] = {"sīt"}
	data.forms["pres_ind_3p"] = {"sint"}

	data.forms["past_ind_1s"] = {"was"}
	data.forms["past_ind_2s"] = {"wāri"}
	data.forms["past_ind_3s"] = {"was"}
	data.forms["past_ind_1p"] = {"wārun"}
	data.forms["past_ind_2p"] = {"wārut"}
	data.forms["past_ind_3p"] = {"wārun"}
	
	data.forms["pres_sub_1s"] = {"sī"}
	data.forms["pres_sub_2s"] = {"sīs", "sīst"}
	data.forms["pres_sub_3s"] = {"sī"}
	data.forms["pres_sub_1p"] = {"sīn"}
	data.forms["pres_sub_2p"] = {"sīt"}
	data.forms["pres_sub_3p"] = {"sīn"}

	data.forms["past_sub_1s"] = {"wāri"}
	data.forms["past_sub_2s"] = {"wāris", "wārist"}
	data.forms["past_sub_3s"] = {"wāri"}
	data.forms["past_sub_1p"] = {"wārin"}
	data.forms["past_sub_2p"] = {"wārit"}
	data.forms["past_sub_3p"] = {"wārin"}
	
	data.forms["imp_s"] = {"wes"}
	data.forms["imp_p"] = {"wesat"}
	
	data.forms["pres_part"] = {"wesandi"}
	data.forms["past_part"] = {"geweson"}
	
	table.insert(data.categories, "Old Dutch suppletive verbs")
end

local function add_asterisks(forms, data)
	for _, form in ipairs(forms) do
		for i, subform in ipairs(data.forms[form]) do
			data.forms[form][i] = "*" .. subform
		end
	end
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)

	local parent_args = frame:getParent().args
	local conj_type = (frame.args["conj"] or parent_args["conj"]) or "st"

	if not conj_data[conj_type] then
		error("Unknown conjugation '" .. conj_type .. "'")
	end
	
	local data = {forms = {}, categories = {}}
	
	data.head = parent_args["head"] or nil

	local args = require("Module:parameters").process(parent_args, conj_data[conj_type].params, true)
	
	-- Override for templates
	if not args[1] then
		setmetatable(args, {__index = function(self, key)
			return "{{{" .. key .. "}}}"
		end
		})
	end
	
	-- Generate the forms
	if parent_args.irr then
		table.insert(data.categories, "Old Dutch irregular verbs")
		if conj_data.irregular[parent_args.irr] then
			conj_data.irregular[parent_args.irr](data)
		else
			conj_data[conj_type](args, data)
		end
	else
		conj_data[conj_type](args, data)
	end

	-- Make the table
	return make_table(data)
end

function make_table(data)
	local function show_form(form)
		if not form then
			return "—"
		end
		
		local ret = {}
		
		for key, subform in ipairs(form) do
			if mw.title.getCurrentTitle().nsText == "Reconstruction" and subform ~= "—" then
				subform = "*" .. subform
			end
			table.insert(ret, m_links.full_link({lang = lang, term = subform}))
		end
			
		return table.concat(ret, ", ")
	end
	
	local function repl(param)
		if param == "conj_type" then
			return data.conj_type
		else
			return show_form(data.forms[param])
		end
	end
	
	local wikicode = [=[
<div class="NavFrame" style="width: 42em">
<div class="NavHead" style="background-color:#CCCCFF;">Conjugation of ''{{{inf}}}'' ({{{conj_type}}})</div>
<div class="NavContent">
{| style="width: 100%; border:1px solid #CCCCFF; line-height: 125%; background-color:#F9F9F9; text-align:center; border: 1px solid #CCCCFF;" cellspacing="1" cellpadding="3" cellspacing="1" class="inflection-table"
|- style="background-color:#F2F2FF;"
|-
! style="background-color:#DEDEEE;" | infinitive
| colspan="2" style="background-color:#EFEFEF;" | {{{inf}}}
|-
! style="background-color:#CCCCFF;" | [[indicative mood|indicative]]
! style="background-color:#DEDEEE;" | [[present tense|present]]
! style="background-color:#DEDEEE;" | [[past tense|past]]
|-
! style="background-color:#EEEEEE;" | 1st&nbsp;person&nbsp;singular
| style="background-color:#efefff;" | {{{pres_ind_1s}}}
| style="background-color:#efefff;" | {{{past_ind_1s}}}
|-
! style="background-color:#EEEEEE;" | 2nd&nbsp;person&nbsp;singular
| style="background-color:#efefff;" | {{{pres_ind_2s}}}
| style="background-color:#efefff;" | {{{past_ind_2s}}}
|-
! style="background-color:#EEEEEE;" | 3rd&nbsp;person&nbsp;singular
| style="background-color:#efefff;" | {{{pres_ind_3s}}}
| style="background-color:#efefff;" | {{{past_ind_3s}}}
|-
! style="background-color:#EEEEEE;" | 1st&nbsp;person&nbsp;plural
| style="background-color:#efefff;" | {{{pres_ind_1p}}}
| style="background-color:#efefff;" | {{{past_ind_1p}}}
|-
! style="background-color:#EEEEEE;" | 2nd&nbsp;person&nbsp;plural
| style="background-color:#efefff;" | {{{pres_ind_2p}}}
| style="background-color:#efefff;" | {{{past_ind_2p}}}
|-
! style="background-color:#EEEEEE;" | 3rd&nbsp;person&nbsp;plural
| style="background-color:#efefff;" | {{{pres_ind_3p}}}
| style="background-color:#efefff;" | {{{past_ind_3p}}}
|-
! style="background-color:#CCCCFF;" | [[subjunctive mood|subjunctive]]
! style="background-color:#eeeede;" | present
! style="background-color:#eeeede;" | past
|-
! style="background-color:#eeeeee;" | 1st&nbsp;person&nbsp;singular
| style="background-color:#ffffef;" | {{{pres_sub_1s}}}
| style="background-color:#ffffef;" | {{{past_sub_1s}}}
|-
! style="background-color:#eeeeee;" | 2nd&nbsp;person&nbsp;singular
| style="background-color:#ffffef;" | {{{pres_sub_2s}}}
| style="background-color:#ffffef;" | {{{past_sub_2s}}}
|-
! style="background-color:#eeeeee;" | 3rd&nbsp;person&nbsp;singular
| style="background-color:#ffffef;" | {{{pres_sub_3s}}}
| style="background-color:#ffffef;" | {{{past_sub_3s}}}
|-
! style="background-color:#eeeeee;" | 1st&nbsp;person&nbsp;plural
| style="background-color:#ffffef;" | {{{pres_sub_1p}}}
| style="background-color:#ffffef;" | {{{past_sub_1p}}}
|-
! style="background-color:#eeeeee;" | 2nd&nbsp;person&nbsp;plural
| style="background-color:#ffffef;" | {{{pres_sub_2p}}}
| style="background-color:#ffffef;" | {{{past_sub_2p}}}
|-
! style="background-color:#eeeeee;" | 3rd&nbsp;person&nbsp;plural
| style="background-color:#ffffef;" | {{{pres_sub_3p}}}
| style="background-color:#ffffef;" | {{{past_sub_3p}}}
|-
! style="background-color:#CCCCFF;" | [[imperative mood|imperative]]
! style="background-color:#eedede;" | present
! rowspan="3" style="background-color:#e0e0e0;" |
|-
! style="background-color:#eeeeee;" | singular
| style="background-color:#ffefef;" | {{{imp_s}}}
|-
! style="background-color:#eeeeee;" | plural
| style="background-color:#ffefef;" | {{{imp_p}}}
|-
! style="background-color:#CCCCFF; font-weight:bold;" | [[participle]]
! style="background-color:#deeede; font-weight:bold;" | [[present tense|present]]
! style="background-color:#deeede; font-weight:bold;" | [[past tense|past]]
|-
! style="background-color:#eeeeee; font-weight:bold;" |
| style="background-color:#efffef;" | {{{pres_part}}} 
| style="background-color:#efffef;" | {{{past_part}}}
|}</div></div>]=]

	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. m_utils.format_categories(data.categories, lang)
end

return export