Module:zlw-ocs-verb


local export = {}


--[=[

Authorship: Zhnka

]=]

--[=[

TERMINOLOGY:

-- "slot" = A particular combination of case/gender/number.
	 Example slot names for verbs are "pf_3s" (present 3rd person singular). Each slot is filled with zero or more forms.

-- "form" = The conjugated Old Czech form representing the value of a given slot.

-- "lemma" = The dictionary form of a given Old Czech term – the infinitive form.
]=]

local lang = require("Module:languages").getByCode("zlw-ocs")
local m_links = require("Module:links")
local m_table = require("Module:table")
local m_string_utilities = require("Module:string utilities")
local iut = require("Module:inflection utilities")
local com = require("Module:zlw-ocs-common")

local current_title = mw.title.getCurrentTitle()
local NAMESPACE = current_title.nsText
local PAGENAME = current_title.text

local u = mw.ustring.char
local rsplit = mw.text.split
local rfind = mw.ustring.find
local rmatch = mw.ustring.match
local rgmatch = mw.ustring.gmatch
local rsubn = mw.ustring.gsub
local ulen = mw.ustring.len
local uupper = mw.ustring.upper


-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end


-- version of rsubn() that returns a 2nd argument boolean indicating whether
-- a substitution was made.
local function rsubb(term, foo, bar)
	local retval, nsubs = rsubn(term, foo, bar)
	return retval, nsubs > 0
end

local input_verb_slots = {
	inf = {""},
	sup = {""},
	vn = {""},
	pf_1s = {""},
	pf_2s = {""},
	pf_3s = {""},
	pf_1d = {""},
	pf_2d = {""},
	pf_3d = {""},
	pf_1p = {""},
	pf_2p = {""},
	pf_3p = {""},
	im_2s = {""},
	im_3s = {""},
	im_1d = {""},
	im_2d = {""},
	im_3d = {""},
	im_1p = {""},
	im_2p = {""},
	im_3p = {""},
	aors_1s = {""},
	aors_2s = {""},
	aors_3s = {""},
	aors_1d = {""},
	aors_2d = {""},
	aors_3d = {""},
	aors_1p = {""},
	aors_2p = {""},
	aors_3p = {""},
	aoras_1s = {""},
	aoras_2s = {""},
	aoras_3s = {""},
	aoras_1d = {""},
	aoras_2d = {""},
	aoras_3d = {""},
	aoras_1p = {""},
	aoras_2p = {""},
	aoras_3p = {""},
	impf_1s = {""},
	impf_2s = {""},
	impf_3s = {""},
	impf_1d = {""},
	impf_2d = {""},
	impf_3d = {""},
	impf_1p = {""},
	impf_2p = {""},
	impf_3p = {""},
	lpart_ms = {""},
	lpart_md = {""},
	lpart_mp = {""},
	lpart_fs = {""},
	lpart_fd = {""},
	lpart_fp = {""},
	lpart_ns = {""},
	lpart_nd = {""},
	lpart_np = {""},
	pass_ms = {""},
	pass_md = {""},
	pass_mp = {""},
	pass_fs = {""},
	pass_fd = {""},
	pass_fp = {""},
	pass_ns = {""},
	pass_nd = {""},
	pass_np = {""},
	ntpart1 = {""},
	ntpart2 = {""},
	ntpart3 = {""},
	spart1 = {""},
	spart2= {""},
	spart3 = {""},
	fut_1s = {""},
	fut_2s = {""},
	fut_3s = {""},
	fut_1d = {""},
	fut_2d = {""},
	fut_1p = {""},
	fut_2p = {""},
	fut_3p = {""},
}


local output_verb_slots = {
	inf = "inf",
	sup = "sup",
	vn = "vn",
	pf_1s = {""},
	pf_2s = {""},
	pf_3s = {""},
	pf_1d = {""},
	pf_2d = {""},
	pf_3d = {""},
	pf_1p = {""},
	pf_2p = {""},
	pf_3p = {""},
	im_2s = {""},
	im_3s = {""},
	im_1d = {""},
	im_2d = {""},
	im_3d = {""},
	im_1p = {""},
	im_2p = {""},
	im_3p = {""},
	aors_1s = {""},
	aors_2s = {""},
	aors_3s = {""},
	aors_1d = {""},
	aors_2d = {""},
	aors_3d = {""},
	aors_1p = {""},
	aors_2p = {""},
	aors_3p = {""},
	aoras_1s = {""},
	aoras_2s = {""},
	aoras_3s = {""},
	aoras_1d = {""},
	aoras_2d = {""},
	aoras_3d = {""},
	aoras_1p = {""},
	aoras_2p = {""},
	aoras_3p = {""},
	impf_1s = {""},
	impf_2s = {""},
	impf_3s = {""},
	impf_1d = {""},
	impf_2d = {""},
	impf_3d = {""},
	impf_1p = {""},
	impf_2p = {""},
	impf_3p = {""},
	lpart_ms = {""},
	lpart_md = {""},
	lpart_mp = {""},
	lpart_fs = {""},
	lpart_fd = {""},
	lpart_fp = {""},
	lpart_ns = {""},
	lpart_nd = {""},
	lpart_np = {""},
	pass_ms = {""},
	pass_md = {""},
	pass_mp = {""},
	pass_fs = {""},
	pass_fd = {""},
	pass_fp = {""},
	pass_ns = {""},
	pass_nd = {""},
	pass_np = {""},
	ntpart1 = {""},
	ntpart2 = {""},
	ntpart3 = {""},
	spart1 = {""},
	spart2= {""},
	spart3 = {""},
	fut_1s = {""},
	fut_2s = {""},
	fut_3s = {""},
	fut_1d = {""},
	fut_2d = {""},
	fut_1p = {""},
	fut_2p = {""},
	fut_3p = {""},
}

local function if_rsplit(stem)
	if stem ~= nil then
		return rsplit(stem, ",")
	else
		return stem
	end
end

local function get_output_verb_slots(alternant_multiword_spec)
	return output_verb_slots
end


local function combine_stem_ending(stem, ending)
	if stem == "?" then
		return "?"
	else
		return stem .. ending
	end
end

local function add(base, slot, stems, endings, footnote)
	if stems then
		stems = iut.combine_form_and_footnotes(stems, footnote)
	end
	iut.add_forms(base.forms, slot, stems, endings, combine_stem_ending)
end

local function add_normal_conj(base, stems,
	inf, sup, vn,
	pf_1s, pf_2s, pf_3s, pf_1d, pf_2d, pf_1p, pf_2p, pf_3p,
	im_2s, im_1d, im_2d, im_1p, im_2p,
	aors_1s, aors_2s, aors_1d, aors_2d,
	aors_1p, aors_2p, aors_3p,
	impf_1s, impf_2s, impf_1d, impf_2d,
	impf_1p, impf_2p, impf_3p,
	lpart_ms, lpart_fs, lpart_ns, lpart_fd, lpart_mp, lpart_fp,
	ntpart1, ntpart2, ntpart3,
	spart1, spart2, spart3,
	pass_ms, pass_fs, pass_ns, pass_fd, pass_mp, pass_fp,
	footnote)
	if stems then
		stems = iut.combine_form_and_footnotes(stems, footnote)
	end	
	add(base, "inf", stems, inf)
	add(base, "sup", stems, sup)
	add(base, "vn", stems, vn)
	add(base, "pf_1s", stems, pf_1s)
	add(base, "pf_2s", stems, pf_2s)
	add(base, "pf_3s", stems, pf_3s)
	add(base, "pf_1d", stems, pf_1d)
	add(base, "pf_2d", stems, pf_2d)
	add(base, "pf_1p", stems, pf_1p)
	add(base, "pf_2p", stems, pf_2p)
	add(base, "pf_3p", stems, pf_3p)
	add(base, "im_2s", stems, im_2s)
	add(base, "im_1d", stems, im_1d)
	add(base, "im_2d", stems, im_2d)
	add(base, "im_1p", stems, im_1p)
	add(base, "im_2p", stems, im_2p)
	add(base, "aors_1s", stems, aors_1s)
	add(base, "aors_2s", stems, aors_2s)
	add(base, "aors_1d", stems, aors_1d)
	add(base, "aors_2d", stems, aors_2d)
	add(base, "aors_1p", stems, aors_1p)
	add(base, "aors_2p", stems, aors_2p)
	add(base, "aors_3p", stems, aors_3p)
	add(base, "impf_1s", stems, impf_1s)
	add(base, "impf_2s", stems, impf_2s)
	add(base, "impf_1d", stems, impf_1d)
	add(base, "impf_2d", stems, impf_2d)
	add(base, "impf_1p", stems, impf_1p)
	add(base, "impf_2p", stems, impf_2p)
	add(base, "impf_3p", stems, impf_3p)
	add(base, "lpart_ms", stems, lpart_ms)
	add(base, "lpart_fs", stems, lpart_fs)
	add(base, "lpart_ns", stems, lpart_ns)
	add(base, "lpart_fd", stems, lpart_fd)
	add(base, "lpart_mp", stems, lpart_mp)
	add(base, "lpart_fp", stems, lpart_fp)
	add(base, "ntpart1", stems, ntpart1)
	add(base, "ntpart2", stems, ntpart2)
	add(base, "ntpart3", stems, ntpart3)
	add(base, "spart1", stems, spart1)
	add(base, "spart2", stems, spart2)
	add(base, "spart3", stems, spart3)
	add(base, "pass_ms", stems, pass_ms)
	add(base, "pass_fs", stems, pass_fs)
	add(base, "pass_ns", stems, pass_ns)
	add(base, "pass_fd", stems, pass_fd)
	add(base, "pass_mp", stems, pass_mp)
	add(base, "pass_fp", stems, pass_fp)
end

local function add_aoras_conj(base, stems,
	aoras_1s, aoras_2s, aoras_1d, aoras_2d,
	aoras_1p, aoras_2p, aoras_3p,
	footnote)
	if stems then
		stems = iut.combine_form_and_footnotes(stems, footnote)
	end	
	add(base, "aoras_1s", stems, aoras_1s)
	add(base, "aoras_2s", stems, aoras_2s)
	add(base, "aoras_1d", stems, aoras_1d)
	add(base, "aoras_2d", stems, aoras_2d)
	add(base, "aoras_1p", stems, aoras_1p)
	add(base, "aoras_2p", stems, aoras_2p)
	add(base, "aoras_3p", stems, aoras_3p)
end 

local function add_fut_conj(base, stems,
	fut_1s, fut_2s, fut_3s, fut_1d, fut_2d, fut_1p, fut_2p, fut_3p,
	footnote)
	if stems then
		stems = iut.combine_form_and_footnotes(stems, footnote)
	end	
	add(base, "fut_1s", stems, fut_1s)
	add(base, "fut_2s", stems, fut_2s)
	add(base, "fut_3s", stems, fut_3s)
	add(base, "fut_1d", stems, fut_1d)
	add(base, "fut_2d", stems, fut_2d)
	add(base, "fut_1p", stems, fut_1p)
	add(base, "fut_2p", stems, fut_2p)
	add(base, "fut_3p", stems, fut_3p)
end 

local conjs = {}

conjs["normal"] = function(base)
	
	if class == "1a" then
		if vowel_alt then
			a_pf2 = com.apply_first_palatalization(vowel_alt).."e"
			a_aors = com.apply_first_palatalization(vowel_alt).."e"
			a_impf = com.apply_first_palatalization(vowel_alt).."ie"
			a_aoras2 = com.apply_first_palatalization(vowel_alt).."e"
			a_lpart1 = stem.."l"
			a_lpart2 = vowel_alt.."l"
			a_pass1 = com.apply_first_palatalization(vowel_alt).."en"
			a_spart23 = vowel_alt
			
		if rmatch(vowel_alt, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(vowel_alt, ".*r"..com.cons_c.."$") and not rmatch(vowel_alt, ".*st$") then
			a_im1 = com.apply_second_palatalization(vowel_alt).."i"
			a_im2 = com.apply_second_palatalization(vowel_alt).."ě"
			a_im3 = com.apply_second_palatalization(vowel_alt).."ěm"
		else
		a_im1 = {com.onlyndt(com.apply_second_palatalization(vowel_alt)), com.apply_second_palatalization(vowel_alt).."i"}
		a_im2 = {com.onlyndt(com.apply_second_palatalization(vowel_alt)), com.apply_second_palatalization(vowel_alt).."ě"}
		a_im3 = {com.onlyndt(com.apply_second_palatalization(vowel_alt)).."me", com.apply_second_palatalization(vowel_alt).."ěm"}
		end
		else
			a_pf2 = com.apply_first_palatalization(stem).."e"
			a_aoras2 = com.apply_first_palatalization(stem).."e"
			a_aors = com.apply_first_palatalization(stem).."e"
			a_impf = com.apply_first_palatalization(stem).."ie"
			a_lpart1 = stem.."l"
			a_pass1 = com.apply_first_palatalization(stem).."en"
		if rmatch(stem, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(stem, ".*r"..com.cons_c.."$") and not rmatch(stem, ".*st$") then
			a_im1 = com.apply_second_palatalization(stem).."i"
			a_im2 = com.apply_second_palatalization(stem).."ě"
			a_im3 = com.apply_second_palatalization(stem).."ěm"
		else
			a_im1 = {com.onlyndt(com.apply_second_palatalization(stem)), com.apply_second_palatalization(stem).."i"}
			a_im2 = {com.onlyndt(com.apply_second_palatalization(stem)), com.apply_second_palatalization(stem).."ě"}
			a_im3 = {com.onlyndt(com.apply_second_palatalization(stem)).."me", com.apply_second_palatalization(stem).."ěm"}
		end
		end
		a_pf1 = stem.."u"
		a_pf3 = stem.."ú"
		a_aoras = stem
		a_localpart1 = stem.."l"
		a_ntpart1 = stem.."a"
		a_ntpart23 = stem.."úc"
		a_spart1 = stem
		a_sup = com.apply_vowel_alternation("quant", rmatch(inf, "(.*)i$"))
		a_vn = a_pass1.."ie"
	end
	
		
	if class == "1aa" then
		if vowel_alt then
			a_pf2 = com.apply_first_palatalization(vowel_alt).."e"
			a_aors = com.apply_first_palatalization(vowel_alt).."e"
			a_impf = com.apply_first_palatalization(vowel_alt).."ie"
			a_lpart1 = stem.."l"
			a_lpart2 = vowel_alt.."l"
			a_pass1 = com.apply_first_palatalization(vowel_alt).."en"
			a_spart23 = vowel_alt
			
		if rmatch(vowel_alt, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(vowel_alt, ".*r"..com.cons_c.."$") and not rmatch(vowel_alt, ".*st$") then
			a_im1 = com.apply_second_palatalization(vowel_alt).."i"
			a_im2 = com.apply_second_palatalization(vowel_alt).."ě"
			a_im3 = com.apply_second_palatalization(vowel_alt).."ěm"
		else
		a_im1 = {com.onlyndt(com.apply_second_palatalization(vowel_alt)), com.apply_second_palatalization(vowel_alt).."i"}
		a_im2 = {com.onlyndt(com.apply_second_palatalization(vowel_alt)), com.apply_second_palatalization(vowel_alt).."ě"}
		a_im3 = {com.onlyndt(com.apply_second_palatalization(vowel_alt)).."me", com.apply_second_palatalization(vowel_alt).."ěm"}
		end
		else
			a_pf2 = com.apply_first_palatalization(stem).."e"
			a_aors = com.apply_first_palatalization(stem).."e"
			a_impf = com.apply_first_palatalization(stem).."ie"
			a_lpart1 = stem.."l"
			a_pass1 = com.apply_first_palatalization(stem).."en"
		if rmatch(stem, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(stem, ".*r"..com.cons_c.."$") and not rmatch(stem, ".*st$") then
			a_im1 = com.apply_second_palatalization(stem).."i"
			a_im2 = com.apply_second_palatalization(stem).."ě"
			a_im3 = com.apply_second_palatalization(stem).."ěm"
		else
			a_im1 = {com.onlyndt(com.apply_second_palatalization(stem)), com.apply_second_palatalization(stem).."i"}
			a_im2 = {com.onlyndt(com.apply_second_palatalization(stem)), com.apply_second_palatalization(stem).."ě"}
			a_im3 = {com.onlyndt(com.apply_second_palatalization(stem)).."me", com.apply_second_palatalization(stem).."ěm"}
		end
		end
		a_pf1 = stem.."u"
		a_pf3 = stem.."ú"
		a_localpart1 = stem.."l"
		a_ntpart1 = stem.."a"
		a_ntpart23 = stem.."úc"
		a_spart1 = stem
		a_sup = com.apply_vowel_alternation("quant", rmatch(inf, "(.*)i$"))
		a_vn = a_pass1.."ie"
	end
	
	if class == "1b" then
		bare = rmatch(stem, "(.*)[mn]$")
		if rmatch(inf, ".*léti$") then
		bare = rmatch(inf, "(.*)éti$")
		a_aors = bare.."e"
		a_lpart1 = bare.."el"
		a_pass1 = bare.."et"
		a_pass2 = bare.."et"
		a_spart1 = {bare.."e"..rmatch(stem, ".*([mn])$"), bare.."ev"}
		a_spart23 = {bare.."e"..rmatch(stem, ".*([mn])$"), bare.."ev"}
		a_sup = bare.."et"
		elseif rmatch(inf, ".*úti$") then
		bare = rmatch(inf, "(.*)úti$")
		a_aors = bare.."u"
		a_lpart1 = bare.."ul"
		a_pass1 = bare.."ut"
		a_pass2 = bare.."ut"
		a_spart1 = {bare.."e"..rmatch(stem, ".*([mn])$"), bare.."uv"}
		a_spart23 = {bare.."e"..rmatch(stem, ".*([mn])$"), bare.."uv"}
		a_sup = bare.."ut"
		else
		bare = rmatch(inf, "(.*)ieti$")
		a_aors = bare.."ě"
		a_lpart1 = com.onlyndt(bare).."al"
		a_lpart2 = bare.."ěl"
		a_pass1 = com.onlyndt(bare).."at"
		a_pass2 = bare.."ět"
		a_spart1 = {bare.."e"..rmatch(stem, ".*([mn])$"), com.onlyndt(bare).."av"}
		a_spart23 = {bare.."e"..rmatch(stem, ".*([mn])$"), bare.."ěv"}
		a_sup = com.onlyndt(bare).."at"
		end
		a_pf1 = stem.."u"
		a_pf2 = stem.."e"
		a_pf3 = stem.."ú"
		a_im1 = stem.."i"
		a_im2 = stem.."ě"
		a_im3 = stem.."ěm"
		a_impf = stem.."ie"
		a_ntpart1 = stem.."a"
		a_ntpart23 = stem.."úc"
		a_vn = a_pass2.."ie"
	end

	if class == "1c" then
		a_pf1 = stem.."u"
		a_pf2 = com.apply_first_palatalization(stem).."e"
		a_pf3 = stem.."ú"
		a_im1 = com.apply_first_palatalization(stem).."i"
		a_im2 = com.apply_first_palatalization(stem).."ě"
		a_im3 = a_im2.."m"
		a_aors = com.apply_first_palatalization(stem).."ě"
		a_impf = com.apply_first_palatalization(stem).."ie"
		a_lpart1 = com.apply_first_palatalization(stem).."ěl"
		a_pass1 = com.apply_first_palatalization(stem).."ěn"
		a_vn = com.apply_first_palatalization(stem).."ěnie"
		a_ntpart1 = stem.."a"
		a_ntpart23 = stem.."úc"
		a_spart1 = com.apply_first_palatalization(stem).."ěv"
		a_sup = com.apply_first_palatalization(stem).."ět"
	end
	
	if class == "1d" then
		my2 = true
		stem = rmatch(inf, "(.*)ti")
		shortstem = com.apply_vowel_alternation("quant", stem)
		if not rmatch(inf, "[bpmvfdtnl]íti$") then 
			a_pf1 = shortstem.."ju"
			a_pf2 = shortstem.."je"
			a_pf3 = shortstem.."jú"
			a_ntpart1 = shortstem.."jě"
			a_ntpart23 = shortstem.."júc"
			a_impf = shortstem.."jie"
		else
			bare = rmatch(inf, "(.*)íti$")
			a_pf1 = com.iotate(bare).."ú"
			if rmatch(inf, ".*líti$") then
			a_pf2 = bare.."é"
			a_ntpart1 = bare.."é"
			a_ntpart23 = com.iotate(bare).."úc"
			a_impf = bare.."é"
			else
			a_pf2 = bare.."ie"
			a_ntpart1 = bare.."ie"
			a_ntpart23 = com.iotate(bare).."úc"
			a_impf = bare.."ie"
			end
			a_pf3 = a_pf1
		end
			a_im1 = stem
			a_im2 = a_im1
			a_im3 = stem.."me"
			a_aors = shortstem
			a_lpart1 = shortstem.."l"
			a_pass1 = shortstem.."t"
			a_spart1 = shortstem.."v"
			a_sup = shortstem.."t"
			a_vn = shortstem.."tie" 
	end
	
	if class == "2a" then
		if not stem then
		stem = rmatch(inf, "(.*)núti")
		end
		if vowel_alt ~= nil then
			a_pf2 = vowel_alt.."ne"
			a_im1 = vowel_alt.."ni"
			a_im2 = vowel_alt.."ně"
			a_aoras2 = com.apply_first_palatalization(vowel_alt).."e"
			a_aors = {com.apply_first_palatalization(vowel_alt).."e", stem.."nu"}
			a_lpart2 = {vowel_alt.."l", stem.."nul"}
			a_spart23 = {vowel_alt, stem.."nuv"}
			a_pass1 = {com.apply_first_palatalization(vowel_alt).."en", stem.."nut"}
			a_vn = {com.apply_first_palatalization(vowel_alt).."enie", stem.."nutie"}
			a_impf = vowel_alt.."nie" 
		else
			a_pf2 = stem.."ne"
			a_im1 = stem.."ni"
			a_im2 = stem.."ně"
			a_aoras2 = com.apply_first_palatalization(stem).."e"
			a_aors = {com.apply_first_palatalization(stem).."e", stem.."nu"}
			a_vn = {com.apply_first_palatalization(stem).."enie", stem.."nutie"}
			a_pass1 = {com.apply_first_palatalization(stem).."en", stem.."nut"}
			a_impf = stem.."nie"
		end
		a_pf1 = stem.."nu"
		a_pf3 = stem.."nú"
		a_im3 = a_im2.."m"
		a_aoras = stem
		a_lpart1 = {stem.."l", stem.."nul"}
		a_ntpart1 = stem.."na"
		a_ntpart23 = stem.."núc"
		a_spart1 = {stem, stem.."nuv"}
		a_sup = stem.."nút"
	end
	
	if class == "2b" then
		my2 = true
		stem = rmatch(inf, "(.*n)úti") 
		if vowel_alt ~= nil then
			a_pf2 = vowel_alt.."e"
			a_impf = vowel_alt.."ie" 
		else
			a_pf2 = stem.."e"
			a_impf = stem.."ie"
		end
		a_pf1 = stem.."u"
		a_pf3 = stem.."ú"
		a_im1 = rmatch(inf, "(.*)núti$").."ň"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."u"
		a_lpart1 = stem.."ul"
		a_pass1 = stem.."ut"
		a_ntpart1 = stem.."a"
		a_ntpart23 = stem.."úc"
		a_spart1 = stem.."uv"
		a_sup = stem.."út"
		a_vn = stem.."utie"
	end

	if class == "3a" then
		my2 = true
		if rmatch(inf, ".*ieti$") then
			stem = rmatch(inf, "(.*)ieti$")
		else
		stem = rmatch(inf, "(.*)[ěée]ti") 
		end
		if rmatch(inf, ".*" .. com.cons_c .. "[eé]ti$") then
		a_pf1 = stem.."eju"
		a_pf2 = stem.."é"
		a_pf3 = stem.."ejú"
		a_im1 = stem.."ej"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."e"
		a_impf = {stem.."é", stem.."ejie"}
		if vowel_alt then
		a_lpart1 = com.onlyndt(stem).."al"
		a_lpart2 = stem.."el"
		a_pass1 = com.onlyndt(stem).."án"
		a_pass2 = stem.."en"
		a_spart1 = com.onlyndt(stem).."av"
		a_spart23 = stem.."ev"
		a_sup = com.onlyndt(stem).."at"
		a_vn = stem.."enie" 
		else
		a_lpart1 = stem.."el"
		a_pass1 = stem.."en"
		a_spart1 = stem.."ev"
		a_sup = stem.."et"
		a_vn = stem.."enie"
		end
		a_ntpart1 = stem.."ejě"
		a_ntpart23 = stem.."ejúc"
		
		else
			
		a_pf1 = stem.."ěju"
		a_pf2 = stem.."ie"
		a_pf3 = stem.."ějú"
		a_im1 = stem.."ěj"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."ě"
		a_impf = {stem.."ie", stem.."ějie"}
		if vowel_alt then
		a_lpart1 = com.onlyndt(stem).."al"
		a_lpart2 = stem.."ěl"
		a_pass1 = com.onlyndt(stem).."án"
		a_pass2 = stem.."ěn"
		a_spart1 = com.onlyndt(stem).."av"
		a_spart23 = stem.."ěv"
		a_sup = com.onlyndt(stem).."at"
		a_vn = stem.."ěnie"
		else
		a_lpart1 = stem.."ěl"
		a_pass1 = stem.."ěn"
		a_spart1 = stem.."ěv"
		a_sup = stem.."ět"
		a_vn = stem.."ěnie"
		end
		a_ntpart1 = stem.."ějě"
		a_ntpart23 = stem.."ějúc"
		end
	end

	if class == "3b" then
		if not stem and rmatch(inf, "(.*)ieti$") then
		stem = rmatch(inf, "(.*)ieti$")
		elseif not stem then
		stem = rmatch(inf, "(.*)[áěe]ti$") 
		end
		vowelstem = rmatch(inf, "(.*)ti$")
		if vowel_alt then
			a_lpart1 = com.onlyndt(stem).."al"
			a_lpart2 = stem.."ěl"
			a_pass1 = com.onlyndt(stem).."án"
			a_pass2 = stem.."ěn"
			a_spart1 = com.onlyndt(stem).."av"
			a_spart23 = stem.."ěv"
			a_sup = com.onlyndt(stem).."at"
			a_vn = stem.."ěnie"
		elseif rmatch(stem, ".*oj$") then
			bare = rmatch(stem, "(.*)oj$")
			a_lpart1 = bare.."ál"
			a_pass1 = bare.."án"
			a_spart1 = bare.."av"
			a_sup = stem.."át"
			a_vn = a_pass1.."ie"
		elseif rmatch(inf, ".*áti$") then
			a_lpart1 = stem.."al"
			a_pass1 = stem.."án"
			a_spart1 = stem.."av"
			a_sup = stem.."at"
			a_vn = a_pass1.."ie"
		elseif rmatch(inf, ".*eti$") and not rmatch(inf, ".*ieti$") then
			a_lpart1 = stem.."el"
			a_pass1 = stem.."en"
			a_spart1 = stem.."ev"
			a_sup = stem.."et"
			a_vn = a_pass1.."ie"
		else
			a_lpart1 = stem.."ěl"
			a_pass1 = stem.."ěn"
			a_spart1 = stem.."ěv"
			a_sup = stem.."ět"
			a_vn = a_pass1.."ie"
		end
			
		a_pf1 = com.iotate(stem).."u"
		a_pf2 = stem.."í"
		if rmatch(inf, ".*eti$") and not rmatch(inf, ".*ieti$") then
			a_pf3 = stem.."é"
			a_aors = stem.."e"
			a_ntpart1 = stem.."e"
			a_ntpart23 = stem.."éc"
		elseif rmatch(stem, ".*oj$") then
			a_pf3 = stem.."ie"
			a_aors = bare.."á"
			a_ntpart1 = stem.."ě"
			a_ntpart23 = stem.."iec"
		elseif rmatch(inf, ".*áti$") then
			a_pf3 = stem.."ie"
			a_aors = stem.."a"
			a_ntpart1 = stem.."ě"
			a_ntpart23 = stem.."iec"
		else
			a_pf3 = stem.."ie"
			a_aors = stem.."ě"
			a_ntpart1 = stem.."ě"
			a_ntpart23 = stem.."iec"
		end
		if rmatch(stem, ".*oj$") then
		a_impf = {stem.."ie", rmatch(inf, "(.*á)ti$")}
		a_im1 = bare.."ój"
		a_im2 = a_im1
		a_im3 = {bare.."ójme", bare.."ójim"}
		sup = rmatch(inf, "(.*)i$")
		else
		if rmatch(inf, ".*leti$") then
		a_impf = stem.."é"
		elseif rmatch(inf, ".*áti$") then
		a_impf = stem.."á"
		else
		a_impf = stem.."ie"
		end
		sup = com.apply_vowel_alternation(rmatch(inf, "(.*)i$"))
		if rmatch(stem, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(stem, ".*r"..com.cons_c.."$") and not rmatch(stem, ".*st$") then
		a_im1 = stem.."i"
		a_im2 = a_im1
		a_im3 = stem.."im"
		else
		a_im1 = {com.onlyndt(stem), stem.."i"}
		a_im2 = a_im1
		a_im3 = {com.onlyndt(stem).."me", stem.."im"}
		end
		end
	end
 
	if class == "4" then
		stem = rmatch(inf, "(.*)[ií]ti") 
		if rmatch(inf, ".*l[ií]ti$") then
			a_pf3 = stem.."é"
			a_impf = stem.."é"
			a_pass1 = com.iotate(stem).."en"
			a_ntpart1 = stem.."e"
			a_ntpart23 = stem.."éc"
		else
			a_pf3 = stem.."ie"
			a_impf = stem.."ie"
			a_pass1 = com.iotate(stem).."en"
			a_ntpart1 = stem.."ě"
			a_ntpart23 = stem.."iec" 
		end
		a_pf1 = com.iotate(stem).."u"
		a_pf2 = stem.."í"
		if rmatch(stem, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(stem, ".*r"..com.cons_c.."$") and not rmatch(stem, ".*st$") then
		a_im1 = stem.."i"
		a_im2 = a_im1
		a_im3 = stem.."im"
		else
		a_im1 = {com.apply_vowel_alternation("quant", com.onlyndt(stem)), stem.."i"}
		a_im2 = a_im1
		a_im3 = {com.apply_vowel_alternation("quant", com.onlyndt(stem)).."me", stem.."im"}
		end
		a_aors = stem.."i"
		a_lpart1 = stem.."il"
		a_spart1 = stem.."iv"
		a_sup = stem.."it"
		a_vn = a_pass1.."ie"
	end
	
	if class == "5a" then
		my2 = true
		if rmatch(inf, "(.*)ieti$") then
		stem = rmatch(inf, "(.*)ieti$")
		else
		stem = rmatch(inf, "(.*)[aáěe]ti")
		end
		if rmatch(inf, ".*[aá]ti$") then
		a_pf1 = stem.."aju"
		a_pf2 = stem.."á"
		a_pf3 = stem.."ajú"
		a_im1 = stem.."aj"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."a"
		a_impf = {stem.."á", stem.."ajie"}
		a_lpart1 = rmatch(inf, "(.*[áa])ti$").."l"
		a_pass1 = stem.."án"
		a_ntpart1 = stem.."ajě"
		a_ntpart23 = stem.."ajúc"
		a_spart1 = rmatch(inf, "(.*[áa])ti$").."v"
		a_sup = stem.."at"
		a_vn = rmatch(stem, ".*[áéíóú]"..com.cons_c.."*$") and stem.."anie" or stem.."ánie"
		elseif rmatch(inf, ".*ěti$") or rmatch(inf, ".*ieti$") then
		a_pf1 = stem.."ěju"
		a_pf2 = stem.."ie"
		a_pf3 = stem.."ějú"
		a_im1 = stem.."ěj"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."ě"
		a_impf = stem.."ie"
		a_lpart1 = com.onlyndt(stem).."al"
		a_lpart2 = stem.."ěl"
		a_pass1 = com.onlyndt(stem).."án"
		a_pass2 = stem.."ěn"
		a_ntpart1 = stem.."ějě"
		a_ntpart23 = stem.."ějúc"
		a_spart1 = com.onlyndt(stem).."av"
		a_spart23 = stem.."ěv"
		a_sup = com.onlyndt(stem).."at"
		a_vn = stem.."ěnie"
		elseif rmatch(inf, ".*eti$") and not rmatch(inf, ".*ieti$") then		a_pf1 = stem.."ěju"
		a_pf1 = stem.."eju"
		a_pf2 = stem.."é"
		a_pf3 = stem.."ejú"
		a_im1 = stem.."ej"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."e"
		a_impf = stem.."é"
		a_lpart1 = com.onlyndt(stem).."al"
		a_lpart2 = stem.."el"
		a_pass1 = com.onlyndt(stem).."án"
		a_pass2 = stem.."en"
		a_ntpart1 = stem.."ejě"
		a_ntpart23 = stem.."ejúc"
		a_spart1 = com.onlyndt(stem).."av"
		a_spart23 = stem.."ev"
		a_sup = com.onlyndt(stem).."at"
		a_vn = stem.."enie"

		end
	end

	if class == "5b" then
		if not stem then
		stem = rmatch(inf, "(.*)[aá]ti") 
		shortstem = com.apply_vowel_alternation("quant", stem)
		end
		if vowel_alt then
		shortvstem = com.apply_vowel_alternation("quant", vowel_alt)
		a_pf1 = com.iotate(vowel_alt).."u"
		a_pf2 = com.iotate(vowel_alt).."e"
		a_pf3 = com.iotate(vowel_alt).."ú"
		a_ntpart1 = com.iotate(vowel_alt).."ě"
		a_ntpart23 = com.iotate(vowel_alt).."iec"
		if rmatch(vowel_alt, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(vowel_alt, ".*r"..com.cons_c.."$") and not rmatch(vowel_alt, ".*st$") then
		a_im1 = com.iotate(shortvstem).."i"
		a_im2 = com.iotate(shortvstem).."ě"
		a_im3 = com.iotate(shortvstem).."ěm"
		else
		a_im1 = {com.iotate(shortvstem), com.iotate(shortvstem).."i"}
		a_im2 = {com.iotate(shortvstem), com.iotate(shortvstem).."ě"}
		a_im3 = {com.iotate(shortvstem).."me", com.iotate(shortvstem).."ěm"}
		end
		else
		a_pf1 = com.iotate(stem).."u"
		a_pf2 = com.iotate(stem).."e"
		a_pf3 = com.iotate(stem).."ú"
		a_ntpart1 = com.iotate(stem).."ě"
		a_ntpart23 = com.iotate(stem).."iec"
		if rmatch(stem, ".*"..com.cons_c..com.cons_c.."$") and not rmatch(stem, ".*r"..com.cons_c.."$") and not rmatch(stem, ".*st$") then
		a_im1 = com.iotate(shortstem).."i"
		a_im2 = com.iotate(shortstem).."ě"
		a_im3 = com.iotate(shortstem).."ěm"
		else
		a_im1 = {com.iotate(shortstem), com.iotate(shortstem).."i"}
		a_im2 = {com.iotate(shortstem), com.iotate(shortstem).."ě"}
		a_im3 = {com.iotate(shortstem).."me", com.iotate(shortstem).."ěm"}
		end
		end
		a_aors = stem.."a"
		a_impf = stem.."á"
		a_lpart1 = stem.."al"
		a_pass1 = stem.."án"
		a_spart1 = stem.."av"
		a_sup = stem.."at"
		if rmatch(stem, ".*[áéíýóú]" .. com.cons_c .. "*$") then
		a_vn = stem.."anie"
		else
		a_vn = stem.."ánie"
		end
	end

	if class == "5c" then
	if not stem then
		stem = rmatch(inf, "(.*)áti$")
	end
	if not stem2 then
		stem2 = rmatch(inf, "(.*)áti$")
	end
	if not vowel_alt then
		vowel_alt = stem
	end
		a_pf1 = stem.."u"
		a_pf2 = com.apply_first_palatalization(vowel_alt).."e"
		a_pf3 = stem.."ú"
		a_im1 = {com.apply_second_palatalization(stem).."i", com.apply_second_palatalization(stem)}
		a_im2 = com.apply_second_palatalization(stem)
		a_im3 = com.apply_second_palatalization(stem).."me"
		a_aors = stem2.."a"
		a_impf = {stem2.."á", com.apply_first_palatalization(stem).."ie"}
		a_lpart1 = stem2.."al"
		a_pass1 = stem2.."án"
		a_ntpart1 = stem.."a"
		a_ntpart23 = stem.."úc"
		a_spart1 = stem2.."av"
		a_sup = stem2.."at"
		a_vn = stem2.."ánie"
	end

	if class == "5d" then
		my2 = true
		if rmatch(inf, ".*ovati$") then
		stem = rmatch(inf, "(.*o)vati$")
		bare = rmatch(inf, "(.*)ovati$")
		else
		stem = rmatch(inf, "(.*)v[aá]ti$")
		bare = stem
		end
		a_pf1 = bare.."uju"
		a_pf2 = bare.."uje"
		a_pf3 = bare.."ujú"
		a_im1 = bare.."uj"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."va"
		a_impf = {stem.."vá", bare.."ujie"}
		a_lpart1 = stem.."val"
		a_pass1 = stem.."ván"
		a_ntpart1 = bare.."ujě"
		a_ntpart23 = bare.."ujúc"
		a_spart1 = stem.."vav"
		a_sup = stem.."vat"
		a_vn = stem.."vánie"
	end

	if class == "5e" then
		my2 = true
		shortstem = com.apply_vowel_alternation("quant", rmatch(inf, "(.*)ti$"))
		a_pf1 = shortstem.."ju"
		a_pf2 = shortstem.."je"
		a_pf3 = shortstem.."jú" 
		ntpart1 = shortstem.."jě" 
		ntpart23 = shortstem.."júc" 
		a_im1 = shortstem.."j"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = rmatch(inf, "(.*)ti")
		a_impf = shortstem.."jie"
		a_spart1 = shortstem.."v"
		if rmatch(inf, ".*[á]ti$") then
		a_pass1 = rmatch(inf, "(.*á)ti$").."n"
		a_lpart1 = rmatch(inf, "(.*á)ti$").."l"
		vn = a_pass1.."ie"
		a_sup = shortstem.."t"
		elseif vowel_alt then
		bare = rmatch(shortstem, "(.*)ě$")
		a_pass1 = bare.."án"
		a_pass2 = bare.."ien"
		a_lpart1 = bare.."ál"
		a_lpart2 = bare.."iel"
		spart1 = bare.."áv"
		spart23 = bare.."iev"
		vn = bare.."ienie"
		a_sup = bare.."át"
		else
		a_pass1 = shortstem.."t"
		a_lpart1 = shortstem.."l"
		vn = shortstem.."tie"
		a_sup = shortstem.."t"
		end
	end	

	if class == "6" then
		my2 = true
		stem = rmatch(inf, "(.*)ovati") 
		a_pf1 = stem.."uju"
		a_pf2 = stem.."uje"
		a_pf3 = stem.."ujú"
		a_im1 = stem.."uj"
		a_im2 = a_im1
		a_im3 = a_im1.."me"
		a_aors = stem.."ova"
		a_impf = stem.."ová"
		a_lpart1 = stem.."oval"
		a_pass1 = stem.."ován"
		a_ntpart1 = stem.."ujě"
		a_ntpart23 = stem.."ujúc"
		a_spart1 = stem.."ovav"
		a_sup = stem.."ovat"
		a_vn = stem.."ovánie"
		end

	
	if inf == "býti" then
		my1 = true
		aors = {"by", "bě"}
		impf = {"bie", "budie"}
		im1 = {"buď", "budi"}
		im2 = {"buď", "budě"}
		im3 = {"buďme", "buděm"}
		lpart1 = "byl"
		ntpart1 = {"jsa", "buda"}
		ntpart23 = {"jsúc", "budúc"}
		spart1 = "byv"
		add_normal_conj(base, "",
			"býti", "byt", "bytie",
			"jsem", "jsi", {"jest", "je"}, "jsvě", "jsta", "jsme", "jste", "jsú")
		add_fut_conj(base, "",
			"budu", "budeš", "bude", "budevě", "budeta", "budem", "budete", "budú")
	end
 
 	if inf == "dáti" then
		my1 = true
		my2 = true
		add_normal_conj(base, "",
			{}, {}, {},
			"dám", "dáš", "dá", "dávě", "dáta", "dáme", "dáte", "dadie")
		im1 = "daj"
		im2 = im1
		im3 = im1.."me"
		aors = "da"
		impf = "dadie"
		lpart1 = "dal"
		pass1 = "dán"
		ntpart1 = "dada"
		ntpart23 = "dadúc"
		spart1 = "dav"
		sup = "dat"
		vn = "dánie"
 	end

 	if inf == "jíti" then
		pf1 = "jdu"
		pf2 = "jde"
		pf3 = "jdú"
		im1 = "jdi"
		im2 = "jdě"
		im3 = "jděm"
		aoras = "jid"
		aoras2 = "jide"
		aors = {"jide", "jdě"}
		impf = "jdie"
		add_normal_conj(base, "",
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		"šel", "šla", "šlo", "šle", "šli", "šly")
		pass1 = "jit"
		ntpart1 = "jda"
		ntpart23 = "jdúc"
		spart1 = "šed"
		sup = "jit"
		vn = "jitie"
 	end

 	if rmatch(inf, ".*věděti$") then
		my1 = true
		my2 = true
		add_normal_conj(base, "",
			{}, {}, {},
			{"vědě", "viem"}, "vieš", "vie", "vievě", "vieta", "vieme", "viete", "vědie")
		im1 = "věz"
		im2 = im1
		im3 = im1.."me"
		aors = "vědě"
		impf = "vědie"
		lpart1 = "věděl"
		pass1 = {"věděn", "vědien"}
		ntpart1 = "věda"
		ntpart23 = "vědúc"
		spart1 = "věděv"
		sup = "vědět"
		vn = "věděnie"
 	end

 	if inf == "jmieti" then
		my1 = true
		my2 = true
		add_normal_conj(base, "",
			{}, {}, {},
			"jmám", "jmáš", "jmá", "jmávě", "jmáta", "jmáme", "jmáte", "jmajú")
		im1 = "jměj"
		im2 = im1
		im3 = im1.."me"
		aors = "jmě"
		impf = {"jmie", "jmějie"}
		lpart1 = "jměl"
		pass1 = "jmien"
		ntpart1 = "jmajě"
		ntpart23 = "jmajúc"
		spart1 = "jměv"
		sup = "jmět"
		vn = "jměnie"
 	end

 	if inf == "jiesti" then
		my1 = true
		my2 = true
		add_normal_conj(base, "",
			{}, {}, {},
			"jiem", "jieš", "jie", "jievě", "jieta", "jieme", "jiete", "jědie")
		im1 = "jěz"
		im2 = im1
		im3 = im1.."me"
		aors = "jě"
		impf = "jědie"
		lpart1 = "jědl"
		pass1 = "jěden"
		ntpart1 = "jěda"
		ntpart23 = "jědúc"
		spart1 = "jěd"
		sup = "jěst"
		vn = "jědenie"
	end
	
	if 1 == 1 then
		if not pf1 then
			pf1 = a_pf1
		end
		if not pf2 then
			pf2 = a_pf2
		end
		if not pf3 then
			pf3 = a_pf3
		end
		if not im1 then
			im1 = a_im1
		end
		if not im2 then
			im2 = a_im2
		end
		if not im3 then
			im3 = a_im3
		end
		if not aors then
			aors = a_aors
		end
		if not aoras then
			aoras = a_aoras
		end
		if not aoras2 then
			aoras2 = a_aoras2
		end
		if not impf then
			impf = a_impf
		end
		if not lpart1 then
			lpart1 = a_lpart1
		end
		if not lpart2 then
			if a_lpart2 then
			lpart2 = a_lpart2
			else
			lpart2 = lpart1
			end
		end
		if not pass1 then
			pass1 = a_pass1
		end
		if not pass2 then
			if a_pass2 then
			pass2 = a_pass2
			else
			pass2 = pass1
			end
		end
		if not ntpart1 then
			ntpart1 = a_ntpart1
		end
		if not ntpart23 then
			ntpart23 = a_ntpart23
		end
		if not spart1 then
			spart1 = a_spart1
		end
		if not spart23 then
			if a_spart23 then
			spart23 = a_spart23
			else
			spart23 = spart1
			end
		end
		if not vn then
			vn = a_vn
		end
		if not sup then
			sup = a_sup
		end
		add_normal_conj(base, pf1,
		{}, {}, {},
		"")
		add_normal_conj(base, pf2,
		{}, {}, {},
		{}, "š", "", "vě", "ta", "m", "te", {})
		add_normal_conj(base, pf3,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, "")
		add_normal_conj(base, im1,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		"")
		add_normal_conj(base, im2,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, "vě", "ta", {}, "te")
		add_normal_conj(base, aors,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		"ch", "", "chově", "sta", "chom", "ste", "chu")
		add_normal_conj(base, impf,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		"ch", "še", "chově", "šta", "chom", "šte", "chu")
		add_normal_conj(base, lpart1,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		"", "a", "o", {}, {}, "y")
		add_normal_conj(base, lpart2,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, "e", "i", {}) 
		add_normal_conj(base, "",
		inf, sup, vn,
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, im3, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {},
		ntpart1, {}, {},
		spart1)
		add_normal_conj(base, ntpart23,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {},
		{}, "i", "e")
		add_normal_conj(base, spart23,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {},
		{}, {}, {},
		{}, "ši", "še")
		if tr == "tr" then
		add_normal_conj(base, pass1,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {},
		{}, {}, {},
		{}, {}, {},
		"", "a", "o", {}, {}, "y")
		add_normal_conj(base, pass2,
		{}, {}, {},
		{}, {}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {}, {},
		{}, {}, {}, {}, {}, {},
		{}, {}, {},
		{}, {}, {},
		{}, {}, {}, "ě", "i", {})
		end
	if aoras then
		add_aoras_conj(base, aoras,
			"", {}, "ově", {}, "om", {}, "u")
		add_aoras_conj(base, aoras2,
			{}, "", {}, "ta", {}, "te")
	end
	
if my1 == true then
	memy1 = "(-my)"
else
	memy1 = "(-me/-my)"
end
if my2 == true then
	memy2 = "(-my)"
else
	memy2 = "(-me/-my)"
end
		return
	end
	
		error("Unrecognized verb lemma, should end in '-ý', '-í', '-ův' or '-in': '" .. base.lemma .. "'")
end

local function fetch_footnotes(separated_group)
	local footnotes
	for j = 2, #separated_group - 1, 2 do
		if separated_group[j + 1] ~= "" then
			error("Extraneous text after bracketed footnotes: '" .. table.concat(separated_group) .. "'")
		end
		if not footnotes then
			footnotes = {}
		end
		table.insert(footnotes, separated_group[j])
	end
	return footnotes
end


local function parse_indicator_spec(angle_bracket_spec)
	local inside = rmatch(angle_bracket_spec, "^<(.*)>$")
	assert(inside)
	local base = {forms = {}}
	if inside ~= "" then
		local parts = rsplit(inside, ".", true)
		for _, part in ipairs(parts) do
			if part == "irreg" then
				base.irreg = true
			elseif part == "*" then
				base.red = true
			elseif part == "comp" then
				base.comp = true
			elseif part == "num" then
				base.num = true
			else
				error("Unrecognized indicator '" .. part .. "': '" .. inside .. "'")
			end
		end
	end
	return base
end


local function normalize_all_lemmas(alternant_multiword_spec, pagename)
	iut.map_word_specs(alternant_multiword_spec, function(base)
		if base.lemma == "" then
			base.lemma = pagename
		end
		base.orig_lemma = base.lemma
		base.orig_lemma_no_links = m_links.remove_links(base.lemma)
		base.lemma = base.orig_lemma_no_links
	end)
end


local function detect_indicator_spec(base)
	if base.irreg then
		base.conj = "irreg"
	else
		base.conj = "normal"
	end
end


local function detect_all_indicator_specs(alternant_multiword_spec)
	iut.map_word_specs(alternant_multiword_spec, function(base)
		detect_indicator_spec(base)
	end)
end


local function conjugate_verb(base)
	if not conjs[base.conj] then
		error("Internal error: Unrecognized conjugation type '" .. base.conj .. "'")
	end
	conjs[base.conj](base)
	-- handle_derived_slots_and_overrides(base)
end


-- Process override for the arguments in `args`, storing the results into `forms`. If `do_acc`, only do accusative
-- slots; otherwise, don't do accusative slots.
local function process_overrides(forms, args, do_acc)
	for slot, _ in pairs(input_verb_slots) do
		if args[slot] and not not do_acc == not not slot:find("^acc") then
			forms[slot] = nil
			if args[slot] ~= "-" and args[slot] ~= "—" then
				local segments = iut.parse_balanced_segment_run(args[slot], "[", "]")
				local comma_separated_groups = iut.split_alternating_runs(segments, "%s*,%s*")
				for _, comma_separated_group in ipairs(comma_separated_groups) do
					local formobj = {
						form = comma_separated_group[1],
						footnotes = fetch_footnotes(comma_separated_group),
					}
					iut.insert_form(forms, slot, formobj)
				end
			end
		end
	end
end


local function check_allowed_overrides(alternant_multiword_spec, args)
	local special = alternant_multiword_spec.special or alternant_multiword_spec.surname and "surname" or ""
	for slot, types in pairs(input_verb_slots) do
		if args[slot] then
			local allowed = false
			for _, typ in ipairs(types) do
				if typ == special then
					allowed = true
					break
				end
			end
			if not allowed then
				error(("Override %s= not allowed for %s"):format(slot, special == "" and "regular conjugation" or
					"special=" .. special))
			end
		end
	end
end


local function add_categories(alternant_multiword_spec)
	local cats = {}
	local plpos = m_string_utilities.pluralize(alternant_multiword_spec.pos or "verb")
	local function insert(cattype)
		m_table.insertIfNot(cats, "Old Czech " .. cattype .. " " .. plpos)
	end
	if not alternant_multiword_spec.manual then
		iut.map_word_specs(alternant_multiword_spec, function(base)
			if class == nil then
				insert("irregular")
			elseif rfind(class, "1.*$") then
				insert("class 1")
			elseif rfind(class, "2.*$") then
				insert("class 2")
			elseif rfind(class, "3.*$") then
				insert("class 3")
			elseif rfind(class, "4.*$") then
				insert("class 4")
			elseif rfind(class, "5.*$") then
				insert("class 5")
			elseif rfind(class, "6.*$") then
				insert("class 6") 
			end
		end)
	end
	alternant_multiword_spec.categories = cats
end


local function show_forms(alternant_multiword_spec)
	local lemmas = {}
	local lemmaform = alternant_multiword_spec.forms.nom_m or alternant_multiword_spec.forms.nom_mp
	if lemmaform then
		for _, form in ipairs(lemmaform) do
			table.insert(lemmas, form.form)
		end
	end
	local props = {
		lemmas = lemmas,
		slot_table = get_output_verb_slots(alternant_multiword_spec),
		lang = lang,
	}
	iut.show_forms(alternant_multiword_spec.forms, props)
end

function make_table(alternant_multiword_spec)
	local forms = alternant_multiword_spec.forms

if inf == "býti" then
	table_spec_aorimpf = [=[
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Sigmatic aorist
! style="background:#eff7ff" colspan="3" | Imperfect
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | 1st person
| {aors_1s} || {aors_1d} (-va) || {aors_1p} (-me/-my)
| {impf_1s} || {impf_1d} (-va) || {impf_1p} (-me/-my)
|-
! style="background:#eff7ff" | 2nd person
| {aors_2s} || {aors_2d} (-šta) || {aors_2p} (-šte)
| {impf_2s} || {impf_2d} (-sta) || {impf_2p} (-ste)
|-
! style="background:#eff7ff" | 3rd person
| {aors_2s} || {aors_2d} (-šta) || {aors_3p}
| {impf_2s} || {impf_2d} (-sta) || {impf_3p}
|}
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Conditional
! style="background:#eff7ff" colspan="3" | Future
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | 1st person
| [[bych]] || [[bychově]] (-va) || [[bychom]] (-me/-my)
| {fut_1s} || {fut_1d} (-va) || {fut_1p} (-me/-my)
|-
! style="background:#eff7ff" | 2nd person
| [[by]] || [[bysta]] || [[byste]]
| {fut_2s} || {fut_2d} || {fut_2p}
|-
! style="background:#eff7ff" | 3rd person
| [[by]] || [[by]], [[bysta]] || [[by]], [[bychu]]
| {fut_3s} || {fut_2d} || {fut_3p}
]=] 

elseif aoras then
	table_spec_aorimpf = [=[
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Sigmatic aorist
! style="background:#eff7ff" colspan="3" | Asigmatic aorist
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | 1st person
| {aors_1s} || {aors_1d} (-va)|| {aors_1p} (-me/-my)
| {aoras_1s} || {aoras_1d} (-va) || {aoras_1p} (-me/-my)
|-
! style="background:#eff7ff" | 2nd person
| {aors_2s} || {aors_2d} (-šta) || {aors_2p} (-šte)
| {aoras_2s} || {aoras_2d} || {aoras_2p}
|-
! style="background:#eff7ff" | 3rd person
| {aors_2s} || {aors_2d} (-šta) || {aors_3p} 
| {aoras_2s} || {aoras_2d} || {aoras_3p} (-ú)
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Imperfect
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | 1st person
| {impf_1s} || {impf_1d} (-va) || {impf_1p} (-me/-my)
|-
! style="background:#eff7ff" | 2nd person
| {impf_2s} || {impf_2d} (-sta) || {impf_2p} (-ste)
|-
! style="background:#eff7ff" | 3rd person
| {impf_2s} || {impf_2d} (-sta) || {impf_3p}
]=] 
else
table_spec_aorimpf = [=[
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Sigmatic aorist
! style="background:#eff7ff" colspan="3" | Imperfect
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | 1st person
| {aors_1s} || {aors_1d} (-va) || {aors_1p} (-me/-my)
| {impf_1s} || {impf_1d} (-va) || {impf_1p} (-me/-my)
|-
! style="background:#eff7ff" | 2nd person
| {aors_2s} || {aors_2d} (-šta) || {aors_2p} (-šte)
| {impf_2s} || {impf_2d} (-sta) || {impf_2p} (-ste)
|-
! style="background:#eff7ff" | 3rd person
| {aors_2s} || {aors_2d} (-šta) || {aors_3p}
| {impf_2s} || {impf_2d} (-sta) || {impf_3p}
]=] 
end


table_spec =  [=[<div style="width: 44em;">
<div class="NavFrame inflection-table-verb">
<div class="NavHead" style="background:#eff7ff">{title}{annotation}</div>
<div class="NavContent" style="text-align: left;">
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" | infinitive
! style="background:#eff7ff" | supine
! style="background:#eff7ff" | verbal noun
|-
| {inf}
| {sup}
| {vn}
|}
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Present
! style="background:#eff7ff" colspan="3" | Imperative
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | 1st person
| {pf_1s} || {pf_1d} (-va) || {pf_1p} ]=]..memy1..[=[ 
| – || {im_1d} (-va) || {im_1p} ]=]..memy2..[=[ 
|-
! style="background:#eff7ff" | 2nd person
| {pf_2s} || {pf_2d} || {pf_2p}
| {im_2s} || {im_2d} || {im_2p}
|-
! style="background:#eff7ff" | 3rd person
| {pf_3s} || {pf_2d} || {pf_3p}
| {im_2s} || {im_2d} || {im_2p}
|}
]=]..table_spec_aorimpf..[=[|}
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | L-participle
! style="background:#eff7ff" colspan="3" | Passive participle
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | Masculine
| {lpart_ms}
| {lpart_fs}
| {lpart_mp}
| {pass_ms}
| {pass_fs}
| {pass_mp}
|-
! style="background:#eff7ff" | Feminine
| {lpart_fs}
| {lpart_fd}
| {lpart_fp}
| {pass_fs}
| {pass_fd}
| {pass_fp}
|-
! style="background:#eff7ff" | Neuter
| {lpart_ns}
| {lpart_fd}
| {lpart_fs}
| {pass_ns}
| {pass_fd}
| {pass_fs}
|}
{| class="wikitable" style="text-align: left; border-color: white;"
|-
! style="background:#eff7ff" rowspan="2" |
! style="background:#eff7ff" colspan="3" | Nt-participle
! style="background:#eff7ff" colspan="3" | S-participle
|-
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Dual
! style="background:#eff7ff" | Plural
|-
! style="background:#eff7ff" | Masculine
| {ntpart1}
| colspan ="2" rowspan="3" | {ntpart3}
| {spart1}
| colspan ="2" rowspan="3" | {spart3}
|-
! style="background:#eff7ff" | Feminine
| {ntpart2}
| {spart2}
|-
! style="background:#eff7ff" | Neuter
| {ntpart1}, {ntpart2}
| {spart1}, {spart2}
|}
'''''Note:''' This table shows the most common forms of {inf} around the 13th/14th century. See also [[Appendix:Old Czech verbs]] and [[Appendix:Old Czech pronunciation]].''
<div style="float: left; text-align: left;"></div>
</div>
</div>
</div>]=]	
		
		
	if alternant_multiword_spec.title then
		forms.title = alternant_multiword_spec.title
	else
		forms.title = 'Conjugation of <i lang="zlw-ocs">' .. inf .. '</i>'
	end

	if alternant_multiword_spec.manual then
		forms.annotation = ""
	else
		local ann_parts = {}
		local conjs = {}
		iut.map_word_specs(alternant_multiword_spec, function(base)
			if not class then
				m_table.insertIfNot(conjs, "irregular")
			elseif rfind(class, "1.*$") then
				m_table.insertIfNot(conjs, "class I")
			elseif rfind(class, "2.*$") then
				m_table.insertIfNot(conjs, "class II")
			elseif rfind(class, "3.*$") then
				m_table.insertIfNot(conjs, "class III")
			elseif rfind(class, "4.*$") then
				m_table.insertIfNot(conjs, "class IV")
			elseif rfind(class, "5.*$") then
				m_table.insertIfNot(conjs, "class V")
			elseif rfind(class, "6.*$") then
				m_table.insertIfNot(conjs, "class VI")
			end
		end)
		table.insert(ann_parts, table.concat(conjs, " // "))
		forms.annotation = " (" .. table.concat(ann_parts, ", ") .. ")"
	end
	
		return m_string_utilities.format(
		alternant_multiword_spec.special == "plonly" and table_spec_plonly or
		alternant_multiword_spec.special == "duonly" and table_spec_duonly or
		alternant_multiword_spec.special == "nodual" and table_spec_nodual or
		table_spec, forms
	)
end

function export.do_generate_forms(parent_args, pos, from_headword, def)
	local params = {
		pos = {},
		json = {type = "boolean"}, -- for use with bots
		title = {},
		pagename = {},
		[1] = {},	-- aspect
		[2]	= {},	-- root1-suff1
		[3]	= {},	-- root2-suff2
		[4] = {},
		stem2 = {},
		inf = {},	-- infinitive
		cat	= {},	-- category
		s	= {},	-- s-aorist
		t2	= {},	-- present PP
		t3	= {},	-- past AP
		u2 = {},	-- alternative present root
		pf1 = {},
		pf2 = {},
		pf3 = {},
		im1 = {},
		im2 = {},
		im3 = {},
		vowel_alt = {},
		aors = {},
		aoras = {},
		aoras2 = {},
		impf = {},
		impf2 = {},
		lpart1 = {},	-- l
		lpart2 = {},
		pass1	= {},	-- past PP
		pass2 = {},
		ntpart1 = {},
		ntpart23 = {},
		spart1 = {},
		spart23 = {},
		sup = {},
		vn = {},
		noun = {},	-- verbal noun
		a	= {},	-- aorist
		n	= {},	-- togglable imperfect (~nil/nil)
	}
	for slot, _ in pairs(input_verb_slots) do
		params[slot] = {}
	end

	-- Only default param 1 when displaying the template.
	local args = require("Module:parameters").process(parent_args, params)
	local SUBPAGE = mw.title.getCurrentTitle().subpageText
	local pagename = args.pagename or SUBPAGE
		class = args[3]
		inf = args.inf
		vowel_alt = args.vowel_alt
		stem = args[4]
		stem2 = args.stem2
		tr = args[2]
		pf = args[1]
		pf1 = if_rsplit(args.pf1, ",")
		pf2 = if_rsplit(args.pf2, ",")
		pf3 = if_rsplit(args.pf3, ",")
		im1 = if_rsplit(args.im1, ",")
		im2 = if_rsplit(args.im2, ",")
		im3 = if_rsplit(args.im3, ",")
		aoras = if_rsplit(args.aoras, ",")
		aoras2 = if_rsplit(args.aoras2, ",")
		aors = if_rsplit(args.aors, ",")
		impf = if_rsplit(args.impf, ",")
		lpart1 = if_rsplit(args.lpart1, ",")
		lpart2 = if_rsplit(args.lpart2, ",")
		pass1 = if_rsplit(args.pass1, ",")
		pass2 = if_rsplit(args.pass2, ",")
		ntpart1 = if_rsplit(args.ntpart1, ",")
		ntpart23 = if_rsplit(args.ntpart23, ",")
		spart1 = if_rsplit(args.spart1, ",")
		spart23 = if_rsplit(args.spart23, ",")
		sup = if_rsplit(args.sup, ",")
		vn = if_rsplit(args.vn, ",")
	if not inf then
		if SUBPAGE == "zlw-ocs-conj" then
			inf = "kupovati"
		else
			inf = pagename
		end
	end		
	local parse_props = {
		parse_indicator_spec = parse_indicator_spec,
		allow_default_indicator = true,
		allow_blank_lemma = true,
	}
	local alternant_multiword_spec = iut.parse_inflected_text(args[1], parse_props)
	alternant_multiword_spec.pos = args.pos
	alternant_multiword_spec.title = args.title
	alternant_multiword_spec.forms = {}
	normalize_all_lemmas(alternant_multiword_spec, pagename)
	detect_all_indicator_specs(alternant_multiword_spec)
	check_allowed_overrides(alternant_multiword_spec, args)
	local inflect_props = {
		slot_table = get_output_verb_slots(alternant_multiword_spec),
		inflect_word_spec = conjugate_verb,
	}
	iut.inflect_multiword_or_alternant_multiword_spec(alternant_multiword_spec, inflect_props)
	-- Do non-accusative overrides so they get copied to the accusative forms appropriately.
	process_overrides(alternant_multiword_spec.forms, args)
	-- Do accusative overrides after copying the accusative forms.
	process_overrides(alternant_multiword_spec.forms, args, "do acc")
	add_categories(alternant_multiword_spec)
	if args.json and not from_headword then
		return require("Module:JSON").toJSON(alternant_multiword_spec)
	end
	return alternant_multiword_spec
end

function export.do_generate_forms_manual(parent_args, pos, from_headword, def)
	local params = {
		pos = {},
		special = {},
		json = {type = "boolean"}, -- for use with bots
		title = {},
		[1] = {},	-- aspect
		[2]	= {},	-- transitivity
		[3]	= {},
		[4] = {}, -- present stem if needed
		inf = {},	-- infinitive
		cat	= {},	-- category
		s	= {},	-- s-aorist
		t2	= {},	-- present PP
		t3	= {},	-- past AP
		u2 = {},	-- alternative present root
		vowel_alt = {},
		lpart_ms	= {},	-- l
		pass_ms	= {},	-- past PP
		noun = {},	-- verbal noun
		a	= {},	-- aorist
		n	= {},	-- togglable imperfect (~nil/nil)
	}
	for slot, _ in pairs(input_verb_slots) do
		params[slot] = {}
	end

	local args = require("Module:parameters").process(parent_args, params)
	local alternant_multiword_spec = {
		pos = args.pos,
		special = args.special,
		title = args.title, 
		forms = {},
		manual = true,
		class = args[3]
	}
	check_allowed_overrides(alternant_multiword_spec, args)
	-- Do non-accusative overrides so they get copied to the accusative forms appropriately.
	process_overrides(alternant_multiword_spec.forms, args)
	-- Do accusative overrides after copying the accusative forms.
	process_overrides(alternant_multiword_spec.forms, args, "do acc")
	add_categories(alternant_multiword_spec)
	if args.json and not from_headword then
		return require("Module:JSON").toJSON(alternant_multiword_spec)
	end
	return alternant_multiword_spec
end

function export.show(frame)
	local parent_args = frame:getParent().args
	local alternant_multiword_spec = export.do_generate_forms(parent_args)
	show_forms(alternant_multiword_spec)
	return make_table(alternant_multiword_spec) .. require("Module:utilities").format_categories(alternant_multiword_spec.categories, lang)
end


return export