Jump to content

Module:enm-conj

From Wiktionary, the free dictionary

Called by {{enm-conj-wk}}, {{enm-conj-st}}, and {{enm-conj-irr}}. Do not use directly.


local export = {}

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

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

function table_find (t, pattern)
	for _, v in pairs(t) do
	if v == pattern then 
		return true
	end
	end
end

conj_data = {
	params = {
		-- Basic parameters
		["class"] = {list = true, default = "ed", allow_holes = true},
		["type"] = {},
		["head"] = {},
		[1] = {},
--		[1] = {default = string.sub(mw.title.getCurrentTitle().text, 1, -3)},
		[2] = {},
		[3] = {},
		[4] = {},
		[5] = {},
		-- Form replacement parameters
		["inf"] = {list = true, allow_holes = true},	
		["1s"] = {list = true, allow_holes = true},	
		["2s"] = {list = true, allow_holes = true},	
		["3s"] = {list = true, allow_holes = true},	
		["p"] = {list = true, allow_holes = true},	
		["sub"] = {list = true, allow_holes = true},	
		["imp_p"] = {list = true, allow_holes = true},	
		["part"] = {list = true, allow_holes = true},
		["p_1s"] = {list = true, allow_holes = true},	
		["p_2s"] = {list = true, allow_holes = true},	
		["p_p"] = {list = true, allow_holes = true},
		["p_sub"] = {list = true, allow_holes = true},	
		["p_part"] = {list = true, allow_holes = true},
		-- Principal part replacement parameters
		["1a"] = {list = true, allow_holes = true},
		["2a"] = {list = true, allow_holes = true},
		["3a"] = {list = true, allow_holes = true},
		["4a"] = {list = true, allow_holes = true},
		["5a"] = {list = true, allow_holes = true},
		["obl"] = {list = true, allow_holes = true},
		-- Weak form parameters
		["w_class"] = {list = true, allow_holes = true, default = "none"},
		["w_irr"] = {},
		["w_p"] = {list = true, allow_holes = true},
		["w_part"] = {type = "boolean", default = false},
		-- Strong form parameters
		["s_class"] = {list = true, allow_holes = true, default = "none"},
		["s2"] = {list = "s2_", allow_holes = true},
		["s3"] = {list = "s3_", allow_holes = true},
		["s4"] = {list = "s4_", allow_holes = true},
		-- Miscellaneous parameters
		["s"] = {},
		["i"] = {default = "1"},
		["nopres"] = {type = "boolean", default = false},
		["y"] = {},
		["pf"] = {default = "0"},
		["irr"] = {type = "boolean"},
		["nocat"] = {type = "boolean", default = false},
		-- Aliases
		["c"] = {alias_of = "class", list = true, allow_holes = true},
		["past"] = {alias_of = "w_p", list = true, allow_holes = true},
		["t"] = {alias_of = "type"},
		["w"] = {alias_of = "w_class", list = true, allow_holes = true, default = "none"},
		["sc"] = {alias_of = "s_class", list = true, allow_holes = true, default = "none"},
		["w_s"] = {alias_of = "s"},
		},
}
setmetatable(conj_data, {__call = function(self, args, data, conj_type)
	
	if conj_type ~= "st" and conj_type ~= "wk" and conj_type ~= "irr" then
		error("Unknown conjugation '" .. conj_type .. "'")
	end
	
	if args[1]:sub(1,1) == "*" then
		error("Redundant asterisks")
	end
	
	local function weak_forms(class, stem, alt_stem, irr_stem)
		classnames = {}
		if table_find (class, "irr") then
			s_stem = alt_stem
		else
			s_stem = irr_stem 
		end	
		
		for k, v in ipairs(class) do
			if conj_type == "wk" then
				l = k - 1
			else
				l = k
			end	
			if v == "irr" then 
				if not args[2] then
					error("Past stem required for weak irregular verbs")
				end
				if table_find(classnames, "irregular") ~= true then
					table.insert(classnames, "irregular")
				end
				table.insert(data.forms.past_ind_1s, irr_stem .. "e")
				table.insert(data.forms.past_ind_2s, irr_stem .. "est")
				table.insert(data.forms.past_sub_s, irr_stem .. "e")
				table.insert(data.forms.past_ind_p, irr_stem .. "en")
				table.insert(data.forms.past_ind_p, irr_stem .. "e")
				table.insert(data.forms.past_part, irr_stem)
				if args.nocat == false then
					table.insert(data.categories, "Middle English irregular weak verbs")
				end
			end
			if v == "sl" then 
				if table_find(classnames, "suffixless") ~= true then
					table.insert(classnames, "suffixless")
				end
				table.insert(data.forms.past_ind_1s, (args.w_p[l] or s_stem or stem) .. "e")
				table.insert(data.forms.past_ind_2s, (args.w_p[l] or s_stem or stem) .. "est")
				table.insert(data.forms.past_sub_s, (args.w_p[l] or s_stem or stem) .. "e")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "en")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "e")
				table.insert(data.forms.past_part, args.w_p[l] or s_stem or stem)
			end
			if v == "te" then 
				if table_find(classnames, "in -te") ~= true then
					table.insert(classnames, "in -te")
				end
				table.insert(data.forms.past_ind_1s, (args.w_p[l] or s_stem or stem) .. "te")
				table.insert(data.forms.past_ind_2s, (args.w_p[l] or s_stem or stem) .. "test")
				table.insert(data.forms.past_sub_s, (args.w_p[l] or s_stem or stem) .. "te")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "ten")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "te")
				table.insert(data.forms.past_part, (args.w_p[l] or s_stem or stem) .. "t")
			end
			if v == "de" then 
				if table_find(classnames, "in -de") ~= true then
					table.insert(classnames, "in -de")
				end
				table.insert(data.forms.past_ind_1s, (args.w_p[l] or s_stem or stem) .. "de")
				table.insert(data.forms.past_ind_2s, (args.w_p[l] or s_stem or stem) .. "dest")
				table.insert(data.forms.past_sub_s, (args.w_p[l] or s_stem or stem) .. "de")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "den")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "de")
				table.insert(data.forms.past_part, (args.w_p[l] or s_stem or stem) .. "d")
			end
			if v == "ed" then 
				if table_find(classnames, "in -ed") ~= true then
					table.insert(classnames, "in -ed")
				end
				table.insert(data.forms.past_ind_1s, (args.w_p[l] or s_stem or stem) .. "ed")
				table.insert(data.forms.past_ind_2s, (args.w_p[l] or s_stem or stem) .. "edest")
				table.insert(data.forms.past_sub_s, (args.w_p[l] or s_stem or stem) .. "ed")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "eden")
				table.insert(data.forms.past_ind_p, (args.w_p[l] or s_stem or stem) .. "ede")
				table.insert(data.forms.past_part, (args.w_p[l] or s_stem or stem) .. "ed")
			end
		end
	end
	
	local function build_wk_classnames(names)
		local names = table.concat(names, "/")
		local names = mw.ustring.gsub(names, "-ed/in ", "-ed/")
		local names = mw.ustring.gsub(names, "-te/in ", "-te/")
		local names = mw.ustring.gsub(names, "-te/in ", "-de/")
		return names
	end	
	
	data.forms["inf"] = {args.head or (args[1] .. "en"), (args[1] .. "e")}
	
	data.forms["pres_ind_1s"] = {args[1] .. "e"}
	data.forms["pres_ind_2s"] = {(s_23 or args[1]) .. "est"}
	data.forms["pres_ind_3s"] = {(s_23 or args[1]) .. "eth"}
	data.forms["pres_ind_p"] = {args[1] .. "en", args[1] .. "e"}

	data.forms["pres_sub_s"] = {args[1] .. "e"}
	data.forms["imp_p"] = {args[1] .. "eth", args[1] .. "e"}
	data.forms["pres_part"] = {(args[1] .. "ynge"), (args[1] .. "ende")}
	
	if conj_type == "st" then
		if mw.title.getCurrentTitle().nsText == "Template" then
			data.conj_type = "[[Appendix:Middle English verbs#Strong verbs|strong class 1]]"
		elseif args.class[1] == "ed" then
			error("Class parameter required for strong verbs")
		elseif not args[2] then
			error("Past stem required for strong verbs")
		elseif args.irr == true then
			data.conj_type = "[[Appendix:Middle English verbs#Strong verbs|strong class " .. table.concat(args.class, "/") .. ", irregular]]"
			if args.nocat == false then
				table.insert(data.categories, "Middle English irregular strong verbs")
			end
		else
			data.conj_type = "[[Appendix:Middle English verbs#Strong verbs|strong class " .. table.concat(args.class, "/") .. "]]" 
		end
		
		data.forms["past_ind_1s"] = {args[2]}
		data.forms["past_ind_2s"] = {(args[3] or args[2]) .. "e"}
		data.forms["past_ind_p"] = {(args[3] or args[2]) .. "en", (args[3] or args[2]) .. "e"}

		data.forms["past_sub_s"] = {(args[3] or args[2]) .. "e"}
		data.forms["past_part"] = {(args[4] or args[1]) .. "en", (args[4] or args[1]) .. "e"}
		
		s_23 = args[5]
		
		for _, v in ipairs(args["1a"]) do
			table.insert(data.forms.pres_ind_1s, v .. "e")
			table.insert(data.forms.pres_ind_2s, v .. "est")
			table.insert(data.forms.pres_ind_3s, v .. "eth")
			table.insert(data.forms.inf, v .. "en")
			table.insert(data.forms.inf, v .. "e")
			table.insert(data.forms.pres_ind_p, v .. "en")
			table.insert(data.forms.pres_ind_p, v .. "e")
			table.insert(data.forms.pres_sub_s, v .. "e")
			table.insert(data.forms.pres_part, v .. "ynge")
			table.insert(data.forms.pres_part, v .. "ende")
			table.insert(data.forms.imp_p, v .. "eth")
			table.insert(data.forms.imp_p, v .. "e")
		end
		
		for _, v in ipairs(args["3a"]) do
			table.insert(data.forms.past_ind_2s, v .. "e")
			table.insert(data.forms.past_sub_s, v .. "e")
			table.insert(data.forms.past_ind_p, v .. "en")
			table.insert(data.forms.past_ind_p, v .. "e")
		end
		
		-- Must be inserted here to keep similar second singular past forms together
		table.insert(data.forms.past_ind_2s, args[2])
		
		for _, v in ipairs(args["2a"]) do
			table.insert(data.forms.past_ind_1s, v)
			table.insert(data.forms.past_ind_2s, v)
		end
		for _, v in ipairs(args["4a"]) do
			table.insert(data.forms.past_part, v .. "en")
			table.insert(data.forms.past_part, v .. "e")
		end	
	end
	
	if conj_type == "wk" then
		
		data.forms.past_ind_1s = {}
		data.forms.past_ind_2s = {}
		data.forms.past_ind_p = {}
		data.forms.past_sub_s = {}
		data.forms.past_part = {}
		
		args["w_p"] = args["2a"]
		s_23 = args[3]
		
		ext_classes = args.class

		for k = 1, 10 do
			if ext_classes[k] == nil and ext_classes[k+1] ~= nil then
				table.insert(ext_classes, k, args.class[1])
			end	
		end	

		if #ext_classes < #args["2a"] + 1 then
			repeat 
				table.insert(ext_classes, 2, args.class[1])
			until #ext_classes == #args["2a"] + 1
		end
		
		weak_forms(ext_classes, args[1], args.s, args[2])

		data.conj_type = "[[Appendix:Middle English verbs#Weak verbs|weak " .. build_wk_classnames(classnames) .. "]]"
		
		if args.s_class[1] == "none" and (args.s2[1] or args.s3[1] or args.s4[1]) then
			error("Class parameter required for strong forms")
		end
		
		if args.s_class[1] ~= "none" then
			if not (args.s2[1] or args.s3[1] or args.s4[1]) then
				error("At least one strong past form must be set")
			end
			for _, v in ipairs(args["s3"]) do
				table.insert(data.forms.past_ind_2s, v .. "e")
				table.insert(data.forms.past_sub_s, v .. "e")
				table.insert(data.forms.past_ind_p, v .. "en")
				table.insert(data.forms.past_ind_p, v .. "e")
			end
			for _, v in ipairs(args["s2"]) do
				table.insert(data.forms.past_ind_1s, v)
				table.insert(data.forms.past_ind_2s, v)
			end
			for _, v in ipairs(args["s4"]) do
				table.insert(data.forms.past_part, v .. "en")
				table.insert(data.forms.past_part, v .. "e")
			end	
			if s_set ~= true then
				data.conj_type = data.conj_type .. " or [[Appendix:Middle English verbs#Strong verbs|strong class " .. table.concat(args.s_class, "/") .. "]]"
			end	
			local s_set = true
		end
	end	
	
	if conj_type == "irr" then
		
		data.forms.past_sub_s = {}
		
		if args.type == "been" then
			data.conj_type = "[[Appendix:Middle English verbs#Anomalous verbs|irregular]], [[suppletive]]"
	
			data.forms["inf"] = {"been", "be"}
	
			data.forms["pres_ind_1s"] = {"am", "be"}
			data.forms["pres_ind_2s"] = {"art", "bist"}
			data.forms["pres_ind_3s"] = {"is", "bith"}
			data.forms["pres_ind_p"] = {"aren", "are", "been", "be"}
	
			data.forms["past_ind_1s"] = {"was"}
			data.forms["past_ind_2s"] = {"were"}
			data.forms["past_ind_p"] = {"weren", "were"}
		
			data.forms["pres_sub_s"] = {"be"}
			data.forms["pres_sub_p"] = {"been", "be"}
			data.forms["imp_p"] = {"beth", "be"}
		
			data.forms["pres_part"] = {"beynge", "beende"}
			data.forms["past_part"] = {"been", "be"}
			if args.nocat == false then
				table.insert(data.categories, "Middle English suppletive verbs")
			end
		elseif args.type == "don" then
			data.conj_type = "[[Appendix:Middle English verbs#Anomalous verbs|irregular]]"
		
			data.forms["inf"] = {"don", "do"}
		
			data.forms["pres_ind_1s"] = {"do"}
			data.forms["pres_ind_2s"] = {"dost", "dest"}
			data.forms["pres_ind_3s"] = {"doth", "deth"}
			data.forms["pres_ind_p"] = {"don", "do"}
	
			data.forms["past_ind_1s"] = {"dide"}
			data.forms["past_ind_2s"] = {"didest", "dide"}
			data.forms["past_ind_p"] = {"diden", "dide"}
		
			data.forms["pres_sub_s"] = {"do"}
			data.forms["imp_p"] = {"doth", "do"}
		
			data.forms["pres_part"] = {"doynge", "donde"}
			data.forms["past_part"] = {"don", "do"}
			if args.nocat == false then
				table.insert(data.categories, "Middle English irregular verbs")
			end
		elseif args.type == "gon" then
			data.conj_type = "[[Appendix:Middle English verbs#Anomalous verbs|irregular]], [[suppletive]]"
		
			data.forms["inf"] = {"gon", "go"}
		
			data.forms["pres_ind_1s"] = {"go"}
			data.forms["pres_ind_2s"] = {"gost", "gest"}
			data.forms["pres_ind_3s"] = {"goth", "geth"}
			data.forms["pres_ind_p"] = {"gon", "go"}
	
			data.forms["past_ind_1s"] = {"yede", "wente"}
			data.forms["past_ind_2s"] = {"yedest", "wentest"}
			data.forms["past_ind_p"] = {"yeden", "yede", "wenten", "wente"}
		
			data.forms["pres_sub_s"] = {"go"}
			data.forms["imp_p"] = {"goth", "go"}
		
			data.forms["pres_part"] = {"goynge", "gonde"}
			data.forms["past_part"] = {"gon", "go"}
			if args.nocat == false then
				table.insert(data.categories, "Middle English suppletive verbs")
			end
		elseif args.type == "willen" then
			data.conj_type = "[[Appendix:Middle English verbs#Anomalous verbs|irregular]]"
			
			data.forms["inf"] = {"willen", "wille", "wollen", "wolle"}
		
			data.forms["pres_ind_1s"] = {"wille", "wolle"}
			data.forms["pres_ind_2s"] = {"wilt", "wolt"}
			data.forms["pres_ind_3s"] = {"wille", "wolle"}
			data.forms["pres_ind_p"] = {"willen", "wille", "wollen", "wolle"}
	
			data.forms["past_ind_1s"] = {"wolde"}
			data.forms["past_ind_2s"] = {"woldest", "wolde"}
			data.forms["past_ind_p"] = {"wolden", "wolde"}
		
			data.forms["pres_sub_s"] = {"wille"}
			data.forms["imp_p"] = {"—"}
		
			data.forms["pres_part"] = {"willynge", "willende"}
			data.forms["past_part"] = {"—"}
			if args.nocat == false then
				table.insert(data.categories, "Middle English defective verbs")
			end
		else
			data.conj_type = "[[Appendix:Middle English verbs#Preterite-present verbs|preterite-present]]"
			
			if not args[2] then
				error("Past stem required for preterite-present verbs")
			end
	
			data.forms["inf"] = {args.head or ((args[3] or args[1]) .. "en"), ((args[3] or args[1]) .. "e")}
		
			data.forms["pres_ind_1s"] = {args[1]}
			data.forms["pres_ind_2s"] = {args[4] or (args[1] .. "st")}
			data.forms["pres_ind_3s"] = {args[1]}
			data.forms["pres_ind_p"] = {(args[3] or args[1]) .. "en", (args[3] or args[1]) .. "e"}
	
			data.forms["past_ind_1s"] = {args[2] .. "e"}
			data.forms["past_ind_2s"] = {args[2] .. "est"}
			data.forms["past_ind_p"] = {args[2] .. "en", args[2] .. "e"}
	
			data.forms["pres_sub_s"] = {(args[3] or args[1]) .. "e"}
			data.forms["imp_p"] = {(args[3] or args[1]) .. "eth", (args[3] or args[1]) .. "e"}
		
			data.forms["pres_part"] = {((args[3] or args[1]) .. "ynge"), ((args[3] or args[1]) .. "ende")}
			data.forms["past_part"] = {(args[3] or args[1]) .. "en", (args[3] or args[1]) .. "e"}
			
			if args.w_class[1] ~= "none" then
				table.insert(data.forms.pres_ind_2s, args[2] .. "est")
				table.insert(data.forms.pres_ind_3s, args[2] .. "eth")
			end	
			
			if args.nocat == false then
				table.insert(data.categories, "Middle English preterite-present verbs")
			end
		end
			
		for _, v in ipairs(args["1a"]) do
			table.insert(data.forms.pres_ind_1s, v)
			table.insert(data.forms.pres_ind_3s, v)
		end
		for _, v in ipairs(args["2a"]) do
			table.insert(data.forms.past_ind_1s, v .. "e")
			table.insert(data.forms.past_ind_2s, v .. "est")
			table.insert(data.forms.past_ind_p, v .. "en")
			table.insert(data.forms.past_ind_p, v .. "e")
		end
		for _, v in ipairs(args["obl"]) do
			table.insert(data.forms.inf, v .. "e")
			table.insert(data.forms.pres_ind_p, v .. "en")
			table.insert(data.forms.pres_ind_p, v .. "e")
			table.insert(data.forms.pres_sub_s, v .. "e")
			table.insert(data.forms.imp_p, v .. "eth")
			table.insert(data.forms.imp_p, v .. "e")
		end
		for _, v in ipairs(args["3a"]) do
			table.insert(data.forms.inf, v .. "e")
			table.insert(data.forms.pres_ind_p, v .. "en")
			table.insert(data.forms.pres_ind_p, v .. "e")
			table.insert(data.forms.pres_sub_s, v .. "e")
			table.insert(data.forms.pres_part, v .. "ynge")
			table.insert(data.forms.pres_part, v .. "ende")
			table.insert(data.forms.past_part, v .. "en")
			table.insert(data.forms.past_part, v .. "e")
			table.insert(data.forms.imp_p, v .. "eth")
			table.insert(data.forms.imp_p, v .. "e")
		end
	end
	
	if conj_type ~= "wk" then
		weak_forms(args.w_class, args[1], args.s, args.w_irr)
		if args.w_class[1] ~= "none" and wk_set ~= true then
			data.conj_type = data.conj_type .. " or [[Appendix:Middle English verbs#Weak verbs|weak " .. build_wk_classnames(classnames) .. "]]"
		end	
		local wk_set = true
	end
	
	local function custom_form(forms, slot)
		if table_find(forms, "—") == true then
	    	for k, _ in pairs(forms) do
				slot[k] = nil
	    	end
	    	slot[1] = "—"
			slot[2] = nil
	    else for k, v in pairs(forms) do
				slot[k] = v
	    	end	
			for k, v in pairs(slot) do
				slot[k] = mw.ustring.gsub(v, "ttt", "tt")
			end
			for k, v in pairs(slot) do
				slot[k] = mw.ustring.gsub(v, "ghtt", "ght")
			end
			for k, v in pairs(slot) do
				slot[k] = mw.ustring.gsub(v, "ddd", "dd")
			end
			for k, v in pairs(slot) do
				slot[k] = mw.ustring.gsub(v, "[nsrl][stld][td]", {
					["ntt"] = "nt",
					["stt"] = "st",
					["rtt"] = "rt",
					["ltt"] = "lt",
					["ndd"] = "nd",
					["sdd"] = "sd",
					["rdd"] = "rd",
					["ldd"] = "ld",
					["lld"] = "ld",
					["sdt"] = "st",
					["ndt"] = "nt",
					["rdt"] = "rt",
					["ldt"] = "lt",
					["sst"] = "st",
					["llt"] = "lt",
					["lld"] = "ld",
				})
			end
		end
	end

	custom_form(args.inf, data.forms.inf)
	custom_form(args["1s"], data.forms.pres_ind_1s)
	custom_form(args["2s"], data.forms.pres_ind_2s)
	custom_form(args["3s"], data.forms.pres_ind_3s)
	custom_form(args.p, data.forms.pres_ind_p)
	custom_form(args["sub"], data.forms.pres_sub_s)
	custom_form(args.imp_p, data.forms.imp_p)
	custom_form(args.part, data.forms.pres_part)
	custom_form(args.p_1s, data.forms.past_ind_1s)
	custom_form(args.p_2s, data.forms.past_ind_2s)
	custom_form(args.p_p, data.forms.past_ind_p)
	custom_form(args.p_sub, data.forms.past_sub_s)
	custom_form(args.p_part, data.forms.past_part)
	
	if args["nopres"] == true then
		data.forms.pres_ind_1s = {"—"}
		data.forms.pres_ind_2s = {"—"}
		data.forms.pres_ind_3s = {"—"}
		data.forms.pres_ind_p = {"—"}
		data.forms.pres_sub_s = {"—"}
		data.forms.pres_part = {"—"}
		data.forms.imp_p = {"—"}
		data.forms.pres_part = {"—"}
	end

	if args["i"] == "0" then
		data.forms.inf = {"—"}
		data.forms.imp_p = {"—"}
		data.forms.pres_part = {"—"}
		data.forms.past_part = {"—"}
	end
	
	if args["w_part"] == true then
		table.insert(data.forms.past_part, args[2])
		for _, v in ipairs(args["2a"]) do
			table.insert(data.forms.past_part, v)
		end
	end
	
	for k, v in pairs(data.forms.past_part) do
		data.forms.past_part[k] = mw.ustring.gsub(v, "dd$", "d")
	end
	for k, v in pairs(data.forms.past_part) do
		data.forms.past_part[k] = mw.ustring.gsub(v, "tt$", "t")
	end

	local function find_dash(v)
		if table_find (v, "—") == true then
			table.insert(data.categories, "Middle English defective verbs")
			if def_set ~= true then
				data.conj_type = data.conj_type .. ", [[Appendix:Glossary#defective|defective]]"
			end	
			def_set = true
		end
	end
	for _, v in pairs(data.forms) do
		find_dash(v)
	end
	
	if args.pf ~= "0" then
		local function add_prefix(t)
			for k, v in ipairs(t) do
				if v ~= "0" then 
					t[k] = args.pf .. v
				end
			end	
		end
		for _, v in pairs(data.forms) do
			 add_prefix(v)
		end	
	elseif args.y == "0" or table_find (data.forms.past_part, "—") then
	elseif args.y == "2" then
		yforms = {}
		for k, v in ipairs(data.forms.past_part) do
			yforms[k] = "y" .. v
		end
		if data.forms.past_part[4] then
			y_abbrev = 1
		else for _, item in pairs(yforms) do
				table.insert(data.forms.past_part, item)
			end	
		end
	elseif args.y == "p1" then
		data.forms.past_part[#data.forms.past_part + 1] = "y" .. data.forms.past_part[1]
	elseif args.y == "p2" then
		if not data.forms.past_part[2] then
			error("Parameter 'y' is set to 'p2', but only one past participle was supplied")
		else
			data.forms.past_part[#data.forms.past_part + 1] = "y" .. data.forms.past_part[2]
		end
	elseif args.y == "p3" then
		if not data.forms.past_part[3] then
			error("Parameter 'y' is set to 'p3', but less than three past participles were supplied")
		else
			data.forms.past_part[#data.forms.past_part + 1] = "y" .. data.forms.past_part[3]
		end
	else
		if data.forms.past_part[2] then
			data.forms.past_part[#data.forms.past_part + 1] = "y" .. data.forms.past_part[1]
			data.forms.past_part[#data.forms.past_part + 1] = "y" .. data.forms.past_part[2]
		else
			data.forms.past_part[#data.forms.past_part + 1] = "y" .. data.forms.past_part[1]
		end
	end
	if args.nocat == false then
		if conj_type == "st" then
			for _, v in ipairs(args.class) do
			table.insert(data.categories, "Middle English class " .. v .. " strong verbs")
			end	
		end	
		if args.s_class[1] ~= "none" then
			for _, v in ipairs(args.s_class) do
			table.insert(data.categories, "Middle English class " .. v .. " strong verbs")
			end	
		end
		if conj_type == "wk" or args.w_class[1] ~= "none" then
			table.insert(data.categories, "Middle English weak verbs")
		end	
	end
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"

	local data = {forms = {}, categories = {}}
	
	data.head = parent_args["head"] or nil

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

	-- Make the table
	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
			if subform == "0" then
			elseif subform == "y0" then
			elseif subform == "—" then
				table.insert(ret, "—")
			elseif form == data.forms["past_sub_s"]	then
				table.insert(ret, m_links.full_link({lang = lang, term = subform}) .. [=[<sup style="color:red; font-weight: normal;">1</sup>]=])
			elseif form == data.forms["past_part"] and y_abbrev == 1 then
				table.insert(ret, "(" .. m_links.full_link({lang = lang, alt = "y", term = yforms[key]}) .. ")" .. m_links.full_link({lang = lang, term = subform}))
			else
				table.insert(ret, m_links.full_link({lang = lang, term = subform}))
			end	
		end
			
		return table.concat(ret, ", ")
	end
	
	data.forms["title"] = {}
--	table.insert(data.forms.title, mw.title.getCurrentTitle().text) 

	local function repl(param)
		if param == "title" and mw.title.getCurrentTitle().nsText == "Reconstruction" then
			return "*" .. mw.title.getCurrentTitle().subpageText
		elseif param == "title" then
			return mw.title.getCurrentTitle().subpageText
		elseif param == "conj_type" then
			return data.conj_type
		elseif param == "inf" and not table_find(data.forms.inf , "—" ) then
			return "(to) " .. show_form(data.forms[param])
--		elseif param == "past_part" and y_abbrev == 1 then
--			return "(to) " .. show_form(data.forms["past_part"])
		else
			return show_form(data.forms[param])
		end
	end
if conj_type == "irr" and parent_args.type == "been" then
local wikicode = [=[
<div class="NavFrame" style="max-width: 42em">
<div class="NavHead">Conjugation of ''{{{title}}}'' ({{{conj_type}}})</div>
<div class="NavContent">
{| style="width:100%; margin: 0px;" class="wikitable inflection-table"
|-
! [[infinitive]]
| colspan="3" | {{{inf}}}
|-
| 
! style="width: 50%; white-space: nowrap;" | [[present tense]]
! style="width: 50%; white-space: nowrap;" | [[past tense]]
|-
! style="white-space: nowrap;" | [[first_person#English:_grammar|1st-person]] [[singular]]
| {{{pres_ind_1s}}}
| {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[second_person#English:_grammar|2nd-person]] [[singular]]
| {{{pres_ind_2s}}}
| {{{past_ind_2s}}}
|-
! style="white-space: nowrap;" | [[third_person#English:_grammar|3rd-person]] [[singular]]
| {{{pres_ind_3s}}}
| {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[subjunctive]] [[singular]]
| rowspan="2" | {{{pres_sub_s}}}
| {{{past_ind_2s}}}
|-
! style="white-space: nowrap;" | [[imperative]] [[singular]]
| —
|-
| colspan="3" |
|-
! [[plural]]<sup style="color:red; font-weight: normal;">1</sup>
| {{{pres_ind_p}}}
| rowspan="2" | {{{past_ind_p}}}
|-
! [[subjunctive]] [[plural]]<sup style="color:red; font-weight: normal;">1</sup>
| {{{pres_sub_p}}}
|-
! [[imperative]] [[plural]]
| {{{imp_p}}}
| —
|-
| colspan="3" |
|-
! [[participle]]s
| {{{pres_part}}}
| {{{past_part}}}
|}
<div style="width:100%;text-align:left;background:#f7f8fa">
<div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em">
<strong style="color:red"><sup>1</sup></strong>Sometimes used as a formal 2nd-person singular.
</div></div></div></div>]=]
	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. m_utils.format_categories(data.categories, lang)
elseif table_find(data.forms.imp_p, "—") then
local wikicode = [=[
<div class="NavFrame" style="max-width: 42em">
<div class="NavHead">Conjugation of ''{{{title}}}'' ({{{conj_type}}})</div>
<div class="NavContent">
{| style="width:100%; margin: 0px;" class="wikitable inflection-table"
|-
! [[infinitive]]
| colspan="3" | {{{inf}}}
|-
| 
! style="width: 50%; white-space: nowrap;" | [[present tense]]
! style="width: 50%; white-space: nowrap;" | [[past tense]]
|-
! style="white-space: nowrap;" | [[first_person#English:_grammar|1st-person]] [[singular]]
| {{{pres_ind_1s}}}
| {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[second_person#English:_grammar|2nd-person]] [[singular]]
| {{{pres_ind_2s}}}
| {{{past_ind_2s}}}
|-
! style="white-space: nowrap;" | [[third_person#English:_grammar|3rd-person]] [[singular]]
| {{{pres_ind_3s}}}
| rowspan="2" | {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[subjunctive]] [[singular]]
| {{{pres_sub_s}}}
|-
! style="white-space: nowrap;" | [[imperative]] [[singular]]
| —
| —
|-
| colspan="3" |
|-
! [[plural]]<sup style="color:red; font-weight: normal;">1</sup>
| {{{pres_ind_p}}}
| {{{past_ind_p}}}
|-
! [[imperative]] [[plural]]
| {{{imp_p}}}
| —
|-
| colspan="3" |
|-
! [[participle]]s
| {{{pres_part}}}
| {{{past_part}}}
|}
<div style="width:100%;text-align:left;background:#f7f8fa">
<div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em">
<strong style="color:red"><sup>1</sup></strong>Sometimes used as a formal 2nd-person singular.
</div></div></div></div>]=]
	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. m_utils.format_categories(data.categories, lang)
elseif conj_type == "st" or (parent_args.sc or parent_args.s_class) ~= nil then
local wikicode = [=[
<div class="NavFrame" style="max-width: 42em">
<div class="NavHead">Conjugation of ''{{{title}}}'' ({{{conj_type}}})</div>
<div class="NavContent">
{| style="width:100%; margin: 0px;" class="wikitable inflection-table"
|-
! [[infinitive]]
| colspan="3" | {{{inf}}}
|-
| 
! style="width: 50%; white-space: nowrap;" | [[present tense]]
! style="width: 50%; white-space: nowrap;" | [[past tense]]
|-
! style="white-space: nowrap;" | [[first_person#English:_grammar|1st-person]] [[singular]]
| {{{pres_ind_1s}}}
| {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[second_person#English:_grammar|2nd-person]] [[singular]]
| {{{pres_ind_2s}}}
| {{{past_ind_2s}}}
|-
! style="white-space: nowrap;" | [[third_person#English:_grammar|3rd-person]] [[singular]]
| {{{pres_ind_3s}}}
| {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[subjunctive]] [[singular]]
| rowspan="2" | {{{pres_sub_s}}}
| {{{past_sub_s}}}
|-
! style="white-space: nowrap;" | [[imperative]] [[singular]]
| —
|-
| colspan="3" |
|-
! [[plural]]<sup style="color:red; font-weight: normal;">2</sup>
| {{{pres_ind_p}}}
| {{{past_ind_p}}}
|-
! [[imperative]] [[plural]]
| {{{imp_p}}}
| —
|-
| colspan="3" |
|-
! [[participle]]s
| {{{pres_part}}}
| {{{past_part}}}
|}
<div style="width:100%;text-align:left;background:#f7f8fa">
<div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em">
<strong style="color:red"><sup>1</sup></strong>Replaced by the indicative in later Middle English.<br/><strong style="color:red"><sup>2</sup></strong>Sometimes used as a formal 2nd-person singular.
</div></div></div></div>]=]
	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. m_utils.format_categories(data.categories, lang)
else
local wikicode = [=[
<div class="NavFrame" style="max-width: 42em">
<div class="NavHead">Conjugation of ''{{{title}}}'' ({{{conj_type}}})</div>
<div class="NavContent">
{| style="width:100%; margin: 0px;" class="wikitable inflection-table"
|-
! [[infinitive]]
| colspan="3" | {{{inf}}}
|-
| 
! style="width: 50%; white-space: nowrap;" | [[present tense]]
! style="width: 50%; white-space: nowrap;" | [[past tense]]
|-
! style="white-space: nowrap;" | [[first_person#English:_grammar|1st-person]] [[singular]]
| {{{pres_ind_1s}}}
| {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[second_person#English:_grammar|2nd-person]] [[singular]]
| {{{pres_ind_2s}}}
| {{{past_ind_2s}}}
|-
! style="white-space: nowrap;" | [[third_person#English:_grammar|3rd-person]] [[singular]]
| {{{pres_ind_3s}}}
| rowspan="2" | {{{past_ind_1s}}}
|-
! style="white-space: nowrap;" | [[subjunctive]] [[singular]]
| rowspan="2" | {{{pres_sub_s}}}
|-
! style="white-space: nowrap;" | [[imperative]] [[singular]]
| —
|-
| colspan="3" |
|-
! [[plural]]<sup style="color:red; font-weight: normal;">1</sup>
| {{{pres_ind_p}}}
| {{{past_ind_p}}}
|-
! [[imperative]] [[plural]]
| {{{imp_p}}}
| —
|-
| colspan="3" |
|-
! [[participle]]s
| {{{pres_part}}}
| {{{past_part}}}
|}
<div style="width:100%;text-align:left;background:#f7f8fa">
<div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em">
<strong style="color:red"><sup>1</sup></strong>Sometimes used as a formal 2nd-person singular.
</div></div></div></div>]=]
	return (mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. m_utils.format_categories(data.categories, lang)
end
end

return export