Module:User:Santi2222/eu-conj

Hello, you have come here looking for the meaning of the word Module:User:Santi2222/eu-conj. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Santi2222/eu-conj, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Santi2222/eu-conj in singular and plural. Everything you need to know about the word Module:User:Santi2222/eu-conj you have here. The definition of the word Module:User:Santi2222/eu-conj will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Santi2222/eu-conj, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local lang = require("Module:languages").getByCode("eu")
local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local m_table = require("Module:table")
local m_alloc = require("Module:eu-allocutives")
local m_com = require("Module:eu-common")

local m_string_utilities = require("Module:string utilities")
local rsplit = m_string_utilities.split
local rsub = m_string_utilities.gsub
local rfind = m_string_utilities.find

-- Inflection functions
function export.nornori(frame)
	local args = frame:getParent().args
		
	local data = {
		forms = {},
		info = "",
		categories = {},
	}
	
	-- add the lemma form and generate inflections
	local base = args.pagename or mw.title.getCurrentTitle().text
	data.info = m_links.full_link({lang = lang, alt = base}, "term")
	
	--possible combinations
	local list_1 = {"hi", "hura", "zu", "zuek", "haiek"}
	local list_2 = {"ni", "hura", "gu", "haiek"}
	local list_3 = {"ni", "hi", "hura", "gu", "zu", "zuek", "haiek"}
	local nori_list = {niri = list_1, hirim = list_2, hirif = list_2, hari = list_3, guri = list_1, zuri = list_2, zuei = list_2, haiei = list_3}
	
	--general-use data
	local nor_start ={
		pres = 	{ni = "na", hi = "ha", hura = "da", gu = "ga", zu = "za", zuek = "za", haiek = "da"},
		past = 	{ni = "ninde", hi = "hinde", hura = "ze", gu = "ginde", zu = "zinde", zuek = "zinde", haiek = "ze"},
		hcons = {ni = "ninde", hi = "hinde", hura = "le", gu = "ginde", zu = "zinde", zuek = "zinde", haiek = "le"},
		potpres = {ni = "na", hi = "ha", hura = "da", gu = "ga", zu = "za", zuek = "za", haiek = "da"},
		subpres = {ni = "na", hi = "ha", hura = "da", gu = "ga", zu = "za", zuek = "za", haiek = "da"},
		imp = 	{ni = "", hi = "", hura = "be", gu = "", zu = "", zuek = "", haiek = "be"},
		clcond  = {ni = "bana", hi = "baha", hura = "bada", gu = "baga", zu = "baza", zuek = "baza", haiek = "bada"},
	}
	local infix = {ni = "", hi = "", hura = "", gu = "zki", zu = "zki", zuek = "zki", haiek = "zki"}
	local nori_end = {niri = "t", hirim = "k", hirif = "n", hari = "o", guri = "gu", zuri = "zu", zuei = "zue", haiei = "e"}
	local nor_end_final = {
		pres  = {ni = "", hi = "", hura = "", gu = "", zu = "", zuek = "te", haiek = ""},
		past  = {ni = "n", hi = "n", hura = "n", gu = "n", zu = "n", zuek = "ten", haiek = "n"},
		cond    = {ni = "", hi = "", hura = "", gu = "", zu = "", zuek = "te", haiek = ""},
		hcons = {ni = "ke", hi = "ke", hura = "ke", gu = "ke", zu = "ke", zuek = "kete", haiek = "ke"},
		pcons   = {ni = "keen", hi = "keen", hura = "keen", gu = "keen", zu = "keen", zuek = "keten", haiek = "keen"},
		potpres = {ni = "ke", hi = "ke", hura = "ke", gu = "ke", zu = "ke", zuek = "kete", haiek = "ke"},
		subpres = {ni = "n", hi = "n", hura = "n", gu = "n", zu = "n", zuek = "ten", haiek = "n"},
		imp   = {ni = "", hi = "", hura = "", gu = "", zu = "", zuek = "te", haiek = ""},
		clcond  = {ni = "", hi = "", hura = "", gu = "", zu = "", zuek = "te", haiek = ""},
	}
	local regular_changes = {tt = "dat", tn = "dan", tk = "dak", kn = "an", nn = "nan", kk = "ak", nke = "nake",  = "z", kla = "ala", nla = "nala", tla = "dala"}
	local plural_nor = m_table.listToSet {"gu", "zu", "zuek", "haiek"}
	
	--verb-specific data
	local pres = {jarraiki = "rrai", atxiki = "txe", jariatu = "ri", ibili = "bil", etorri = "tor", joan = "oa", egon = "go", izan = "tzai"}
	if base == "atxiki" or base == "ibili" or base == "etorri" or base == "egon" then
		infix = {ni = "ki", hi = "ki", hura = "ki", gu = "zki", zu = "zki", zuek = "zki", haiek = "zki"}
		nor_start.past = {ni = "nen", hi = "hen", hura = "ze", gu = "gen", zu = "zen", zuek = "zen", haiek = "ze"}
		nor_start.cond = {ni = "banen", hi = "bahen", hura = "bale", gu = "bagen", zu = "bazen", zuek = "bazen", haiek = "bale"}
		nor_start.hcons = {ni = "nen", hi = "hen", hura = "le", gu = "gen", zu = "zen", zuek = "zen", haiek = "le"}
		nor_start.pcons = {ni = "nen", hi = "hen", hura = "ze", gu = "gen", zu = "zen", zuek = "zen", haiek = "ze"}
		nor_start.imp     = {ni = "", hi = "ha", hura = "be", gu = "", zu = "za", zuek = "za", haiek = "be"}
	elseif base == "joan" then
		infix             = {ni = "ki", hi = "ki", hura = "ki", gu = "zki", zu = "zki", zuek = "zki", haiek = "zki"}
		nor_start.pres    = {ni = "n", hi = "h", hura = "dih", gu = "g", zu = "z", zuek = "z", haiek = "dih"}
		nor_start.past    = {ni = "nind", hi = "hind", hura = "zih", gu = "gind", zu = "zind", zuek = "zind", haiek = "zih"}
		nor_start.cond    = {ni = "banind", hi = "bahind", hura = "balih", gu = "bagind", zu = "bazind", zuek = "bazind", haiek = "balih"}
		nor_start.hcons   = {ni = "nind", hi = "hind", hura = "lih", gu = "gind", zu = "zind", zuek = "zind", haiek = "lih"}
		nor_start.pcons   = {ni = "nind", hi = "hind", hura = "zih", gu = "gind", zu = "zind", zuek = "zind", haiek = "zih"}
		nor_start.potpres = {ni = "n", hi = "h", hura = "dih", gu = "g", zu = "z", zuek = "z", haiek = "dih"}
		nor_start.subpres = {ni = "n", hi = "h", hura = "dih", gu = "g", zu = "z", zuek = "z", haiek = "dih"}
		nor_start.imp     = {ni = "", hi = "h", hura = "bih", gu = "", zu = "z", zuek = "z", haiek = "bih"}
		nor_start.clcond  = {ni = "ban", hi = "bah", hura = "badih", gu = "bag", zu = "baz", zuek = "baz", haiek = "badih"}
	elseif base == "izan" then
		nor_start.pres          = {ni = "na", hi = "ha", hura = "", gu = "ga", zu = "za", zuek = "za", haiek = ""}
		nor_start.past          = {ni = "nin", hi = "hin", hura = "zi", gu = "gin", zu = "zin", zuek = "zin", haiek = "zi"}
		nor_start.cond          = {ni = "banin", hi = "bahin", hura = "bali", gu = "bagin", zu = "bazin", zuek = "bazin", haiek = "bali"}
		nor_start.hcons         = {ni = "nin", hi = "hin", hura = "li", gu = "gin", zu = "zin", zuek = "zin", haiek = "li"}
		nor_start.pcons         = {ni = "nin", hi = "hin", hura = "zi", gu = "gin", zu = "zin", zuek = "zin", haiek = "zi"}
		nor_start.pothypo       = {ni = "nen", hi = "hen", hura = "le", gu = "gen", zu = "zen", zuek = "zen", haiek = "le"}
		nor_start.potpast       = {ni = "nen", hi = "hen", hura = "ze", gu = "gen", zu = "zen", zuek = "zen", haiek = "ze"}
		nor_end_final.pothypo   = {ni = "ke", hi = "ke", hura = "ke", gu = "ke", zu = "ke", zuek = "kete", haiek = "ke"}
		nor_end_final.potpast   = {ni = "keen", hi = "keen", hura = "keen", gu = "keen", zu = "keen", zuek = "keten", haiek = "keen"}
		nor_start.dicond        = {ni = "banen", hi = "bahen", hura = "bale", gu = "bagen", zu = "bazen", zuek = "bazen", haiek = "bale"}
		nor_end_final.dicond    = {ni = "", hi = "", hura = "", gu = "", zu = "", zuek = "te", haiek = ""}
		nor_start.subhyp        = {ni = "nen", hi = "hen", hura = "le", gu = "gen", zu = "zen", zuek = "zen", haiek = "le"}
		nor_end_final.subhyp    = {ni = "n", hi = "n", hura = "n", gu = "n", zu = "n", zuek = "ten", haiek = "n"}
		nor_start.subpresla     = {ni = "na", hi = "ha", hura = "da", gu = "ga", zu = "za", zuek = "za", haiek = "da"}
		nor_end_final.subpresla = {ni = "la", hi = "la", hura = "la", gu = "la", zu = "la", zuek = "tela", haiek = "la"}
		nor_start.subpast       = {ni = "nen", hi = "hen", hura = "ze", gu = "gen", zu = "zen", zuek = "zen", haiek = "ze"}
		nor_end_final.subpast   = {ni = "n", hi = "n", hura = "n", gu = "n", zu = "n", zuek = "ten", haiek = "n"}
		nor_start.subpastla     = {ni = "nen", hi = "hen", hura = "ze", gu = "gen", zu = "zen", zuek = "zen", haiek = "ze"}
		nor_end_final.subpastla = {ni = "la", hi = "la", hura = "la", gu = "la", zu = "la", zuek = "tela", haiek = "la"}
		nor_start.imp           = {ni = "", hi = "ha", hura = "be", gu = "", zu = "za", zuek = "za", haiek = "be"}
	end
	local edin_tenses = m_table.listToSet {"potpres", "subpres", "subpresla", "imp", "clcond", "dicond", "pothypo", "potpast", "subhyp", "subpast", "subpastla"}

	--which tenses?
	local tenses_list = {"pres", "past", "hcons", "imp"}
	if base == "ibili" or base == "etorri" or base == "joan" or base == "egon" then
		tenses_list = {"pres", "past", "cond", "hcons", "pcons", "potpres", "imp", "subpres", "clcond"}
	elseif base == "izan" then
		tenses_list = {"pres", "past", "cond", "hcons", "pcons", "potpres", "pothypo", "potpast", "imp", "subpres", "clcond", "dicond", "subhyp", "subpresla", "subpast", "subpastla"}
	end
	
	--generate the values
	local prov_form = ""
	local stem = ""
	for nori, nor_list in pairs(nori_list) do
		for _, nor in ipairs(nor_list) do
			for _, tense in ipairs(tenses_list) do
				--Handle stem alternations
				stem = pres
				if base == "etorri" and plural_nor then
					stem = "to"
				elseif base == "izan" and edin_tenses then
					stem = "ki"
				end
				--Generate form
				prov_form = nor_start .. stem .. infix .. nori_end .. nor_end_final
				--Regular morphological changes
				for original, changed in pairs(regular_changes) do
					prov_form = mw.ustring.gsub(prov_form, original, changed)
				end
				--Store the form
				data.forms = {prov_form}
			end
		end
	end
	
	--notes
	data.notes = {}
	data.allnotes = {}
	local edin = mw.getCurrentFrame():expandTemplate{
		title = 'm',
		args = {"eu", "", "*edin"}
	}
	if base == "ibili" or base == "etorri" or base == "joan" or base == "egon" then
		table.insert(data.notes, {"Archaic or dialectal", "tense_name", {"ccond", "dcond", "fut"}})
	elseif base == "izan" then
		table.insert(data.notes, {"Archaic or dialectal", "tense_name", {"ccond", "dcond", "fut"}})
		table.insert(data.notes, {"Forms belong to the reconstructed verb " .. edin .. ".", "mood_name", {"Potential", "Subjunctive"}})
	end
	
	--categories
	table.insert(data.categories, "Basque synthetic verbs")
	table.insert(data.categories, "Basque intransitive verbs")

	return make_table(data, base, false) .. m_utilities.format_categories(data.categories, lang)
end

--Older tables, only partially adapted
function make_table(data, verb, do_allocutive)
	local data_to_use = do_allocutive and data.alloc or data.forms
	local notes_data = do_allocutive and data.allnotes or data.notes
	
	--miscellaneous stuff
	local allocutive_text = do_allocutive and " allocutive " or " "

	--notes to text
	local notes_text = ""
	for i, note in ipairs(notes_data) do
	    notes_text = notes_text .. i .. ". " .. note
	    if i < #notes_data then notes_text = notes_text .. "<br/>" end
	end
	
	--header
	local head = mw.getCurrentFrame():expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = 'Conjugation of ' .. mw.getContentLanguage():ucfirst(data.info or "") .. ' (NOR-NORI' .. allocutive_text ..  'paradigm)',
			palette = 'custom',
			tall = 'yes',
			 = 'personal forms' --FIXME: in some cases we might not need this
		}
	} .. [=[
|- class="inflection-table-grey"
| colspan="2" rowspan="2" class="vsToggleElement" | Expand all NORI forms
! colspan="7" | NOR (absolutive)
! colspan="2" rowspan="3" style="vertical-align:bottom" | NORI (dative)
|- class="inflection-table-grey"
! <abbr title="first-person singular">1st sg</abbr>
]=] .. (do_allocutive and "" or [=[
! <abbr title="second-person singular informal">2nd sg inf.</abbr>
]=]) .. [=[
! <abbr title="third-person singular">3rd sg</abbr>
! <abbr title="first-person plural">1st pl</abbr>
]=] .. (do_allocutive and "" or [=[
! <abbr title="second-person singular">2nd sg</abbr>
! <abbr title="second-person plural">2nd pl</abbr>
]=]) .. [=[
! <abbr title="third-person plural">3rd pl</abbr>
|- class="inflection-table-grey"
! colspan="2" | Mood / Tense
! class="secondary" | ni
]=] .. (do_allocutive and "" or [=[
! class="secondary" | hi
]=]) .. [=[
! class="secondary" | hura
! class="secondary" | gu
]=] .. (do_allocutive and "" or [=[
! class="secondary" | zu
! class="secondary" | zuek
]=]) .. [=[
! class="secondary" | haiek
]=]

	local endstuff = mw.getCurrentFrame():expandTemplate{
		title = 'inflection-table-bottom',
		args = {
			notes = notes_text
		}
	}
	
	------------------------------
	-------------TODO-------------
	------------------------------
	
	local list_k_n = {}
	local list_n_nan = {}
	local list_ake_nake = {}
	local list_akeen_nakeen = {}
	local list_ala_nala = {}
	local type = nil

	if verb == "jarraiki" or verb == "atxiki" then
		type = "nornori-atxeki"
	elseif verb == "jariatu" then
		type = "nornori-jariatu"
	elseif verb == "ibili" or verb == "etorri" or verb == "joan" or verb == "egon" then
		type = "nornori-ibili"
	else
		type = "nornori-izan"
	end
	
	local wikicode = head

	if type == "nornori-atxeki" then
		wikicode = wikicode .. get_nornori_wikicode(type, notes_data)
		list_k_n = m_table.listToSet {"presnihirif", "preshurahirif", "presguhirif", "preshaiekhirif", "imphurahirif", "imphaiekhirif"}
		list_n_nan = m_table.listToSet {"pastnihirif", "pasthurahirif", "pastguhirif", "pasthaiekhirif"}
		list_ake_nake = m_table.listToSet {"hconsnihirif", "hconshurahirif", "hconsguhirif", "hconshaiekhirif"}
	elseif type == "nornori-jariatu" then
		wikicode = wikicode .. get_nornori_wikicode(type, notes_data)
		list_k_n = m_table.listToSet {"preshurahirif", "preshaiekhirif", "imphurahirif", "imphaiekhirif"}
		list_n_nan = m_table.listToSet {"pasthurahirif", "pasthaiekhirif"}
		list_ake_nake = m_table.listToSet {"hconshurahirif", "hconshaiekhirif"}	
	elseif type == "nornori-ibili" then
		wikicode = wikicode .. get_nornori_wikicode(type, notes_data)
		list_k_n = m_table.listToSet {
			"presnihirif", "preshurahirif", "presguhirif", "preshaiekhirif", 
			"condnihirif", "condhurahirif", "condguhirif", "condhaiekhirif", 
			"imphurahirif", "imphaiekhirif",
			"clcondnihirif", "clcondhurahirif", "clcondguhirif", "clcondhaiekhirif"
		}
		list_n_nan = m_table.listToSet {"pastnihirif", "pasthurahirif", "pastguhirif", "pasthaiekhirif", "subpresnihirif", "subpreshurahirif", "subpresguhirif", "subpreshaiekhirif"}
		list_ake_nake = m_table.listToSet {"hconsnihirif", "hconshurahirif", "hconsguhirif", "hconshaiekhirif", "potpresnihirif", "potpreshurahirif", "potpresguhirif", "potpreshaiekhirif"}
		list_akeen_nakeen = m_table.listToSet {"pconsnihirif", "pconshurahirif", "pconsguhirif", "pconshaiekhirif"}
	elseif type == "nornori-izan" then
		wikicode = wikicode .. get_nornori_wikicode(type, notes_data)
		list_k_n = m_table.listToSet {
			"presnihirif", "preshurahirif", "presguhirif", "preshaiekhirif", 
			"condnihirif", "condhurahirif", "condguhirif", "condhaiekhirif", 
			"imphurahirif", "imphaiekhirif",
			"clcondnihirif", "clcondhurahirif", "clcondguhirif", "clcondhaiekhirif",
			"dicondnihirif", "dicondhurahirif", "dicondguhirif", "dicondhaiekhirif"
		}
		list_n_nan = m_table.listToSet {
			"pastnihirif", "pasthurahirif", "pastguhirif", "pasthaiekhirif", 
			"subpresnihirif", "subpreshurahirif", "subpresguhirif", "subpreshaiekhirif",
			"subhypnihirif", "subhyphurahirif", "subhypguhirif", "subhyphaiekhirif",
			"subpastnihirif", "subpasthurahirif", "subpastguhirif", "subpasthaiekhirif"
		}
		list_ake_nake = m_table.listToSet {
			"hconsnihirif", "hconshurahirif", "hconsguhirif", "hconshaiekhirif", 
			"potpresnihirif", "potpreshurahirif", "potpresguhirif", "potpreshaiekhirif",
			"pothyponihirif", "pothypohurahirif", "pothypoguhirif", "pothypohaiekhirif"
		}
		list_akeen_nakeen = m_table.listToSet {
			"pconsnihirif", "pconshurahirif", "pconsguhirif", "pconshaiekhirif",
			"potpastnihirif", "potpasthurahirif", "potpastguhirif", "potpasthaiekhirif"
		}
		list_ala_nala = m_table.listToSet {
			"subpreslanihirif", "subpreslahurahirif", "subpreslaguhirif", "subpreslahaiekhirif",
			"subpastlanihirif", "subpastlahurahirif", "subpastlaguhirif", "subpastlahaiekhirif"
		}

	end
	
	local function repl(param)
		if param == "info" then
			return mw.getContentLanguage():ucfirst(data.info or "")
		end
		local forms = data.forms
		if not forms then
			return "&mdash;"
		end
		local ret = {}
		for key, subform in ipairs(forms) do
			if subform == "NA" then
				table.insert(ret, "")
			elseif list_k_n then
				table.insert(ret, "/" .. m_links.full_link({lang = lang, term = subform, alt = "n"}))
			elseif list_n_nan then
				table.insert(ret, "/" .. m_links.full_link({lang = lang, term = subform, alt = "nan"}))
			elseif list_ake_nake then
				table.insert(ret, "/" .. m_links.full_link({lang = lang, term = subform, alt = "nake"}))
			elseif list_akeen_nakeen then
				table.insert(ret, "/" .. m_links.full_link({lang = lang, term = subform, alt = "nakeen"}))
			elseif list_ala_nala then
				table.insert(ret, "/" .. m_links.full_link({lang = lang, term = subform, alt = "nala"}))
			else
				table.insert(ret, m_links.full_link({lang = lang, term = subform}))
			end
		end
		return table.concat(ret, "<br/>")
	end
	
	wikicode = wikicode .. endstuff
	
	return mw.ustring.gsub(wikicode, "{{{?(+)}}}", repl)
end


function get_nornori_wikicode(type, notes_data)
	local code = ""
	local newmood = ""
	local moodheader = ""
	local newtense = ""
	local tensenum = 0
	
	--main table-building function
	local function generate_row_by_tenses(remove_persons)
		local tense_row_mainrow = [=[
| {{{TENSE_ABBRniNORI}}}
| {{{TENSE_ABBRhiNORI}}}
| {{{TENSE_ABBRhuraNORI}}}
| {{{TENSE_ABBRguNORI}}}
| {{{TENSE_ABBRzuNORI}}}
| {{{TENSE_ABBRzuekNORI}}}
| {{{TENSE_ABBRhaiekNORI}}}
| class="secondary" | NORI
! class="nowrap" | <abbr title="PERSON">PERSON_ABBR</abbr>
]=]
		local return_tense = ""
		local invalid_combinations = {
			niri = {"ni", "gu"},
			hiri = {"hi", "zu", "zuek"},
			guri = {"ni", "gu"},
			zuri = {"hi", "zu", "zuek"},
			zuei = {"hi", "zu", "zuek"},
			hari = {}, haiei = {}
		}
		local valid_nor = {
			{"niri", "first-person singular", "1st sg"},
			{"hiri", "second-person singular informal", "2nd sg inf"},
			{"hari", "third-person singular", "3rd sg"},
			{"guri", "first-person plural", "1st pl"},
			{"zuri", "second-person singular", "2nd sg"},
			{"zuei", "second-person plural", "2nd pl"},
			{"haiei", "third-person plural", "3rd pl"},
		}
		for i, t in ipairs(valid_nor) do
			local hide_control = [=[
|- class="vsHide inflection-table-COLOR"
]=]
			local tense_name = ""
			local restore_hide = ""
			if t == "hari" then 
				restore_hide = (i ~= #valid_nor) and hide_control or restore_hide
				hide_control = rsub(hide_control, "vsHide ", "")
				tense_name = [=[
! class="vsShow" | TENSE_NAME
]=]
			elseif i == 1 then
				tense_name = [=[
! rowspan="7" | TENSE_NAME
]=]
			end
			--generate the main part of the row
			local main_block = tense_row_mainrow
			--remove specified persons
			for _, person in ipairs(remove_persons) do
				main_block = rsub(main_block, "{{{TENSE_ABBR" .. person .. "NORI}}}", "―")
			end
			--apply substitutions specific to this NORI argument
			main_block = m_com.rsub_multiple(main_block, {"NORI", "PERSON_ABBR", "PERSON"}, {t, t, t})
			for _, subj in ipairs(invalid_combinations]) do
				main_block = rsub(main_block, "{{{TENSE_ABBR" .. subj .. t .. "}}}", "―")
			end
			return_tense = return_tense .. hide_control .. tense_name .. main_block .. restore_hide
		end
		return return_tense
	end

	--now, generate the rows with the previous function
	local wcod_tense = generate_row_by_tenses({})
	local wcod_tense_23 = generate_row_by_tenses({"ni", "gu"})
	local wcod_tense_3 = generate_row_by_tenses({"ni", "hi", "gu", "zu", "zuek"})
	
	--should slots for archaic forms be shown?
	local show_arch = false
	local list_show_arch = m_table.listToSet {"nornori-ibili", "nornori-izan"}
	if list_show_arch then
		show_arch = true
	end
	local list_show_subhyp = m_table.listToSet {"nornori-izan"}
	local show_subhyp = false
	if list_show_subhyp then
		show_subhyp = true
	end
	
	--default data
	local indic_list = {
		{true, 1, "pres", "present", wcod_tense}, 
		{true, 1, "past", "past", wcod_tense}, 
		{true, 0, "cond", "conditional", wcod_tense},
		{true, 1, "hcons", '<abbr title="hypothetic consequence">hyp. cons.</abbr>', wcod_tense}, 
		{true, 0, "pcons", '<abbr title="past consequence">past cons.</abbr>', wcod_tense}, 
		{show_arch, 0, "fut", "future<sup>1</sup>", wcod_tense}
	}
	local potential_list = {
		{true, 0, "potpres", "present", wcod_tense}, 
		{true, 0, "pothypo", "hypothetic", wcod_tense},
		{true, 0, "potpast", "past", wcod_tense}, 
		{show_arch, 0, "clcond", '<abbr title="close conditional">close cond.</abbr><sup>1</sup>', wcod_tense},
		{show_arch, 0, "dicond", '<abbr title="distal conditional">distal cond.</abbr><sup>1</sup>', wcod_tense},
	}
	local subjunctive_list = {
		{true, 0, "subpres", "present", wcod_tense}, 
		{show_subhyp, 0, "subhyp", "hypothetic", wcod_tense},
		{true, 0, "subpast", "past", wcod_tense}, 
	}
	local imperative_list = {
		{true, 1, "imp", "present", wcod_tense_3}, 
	}
	local moods = {
		{"blue", table_nornori_header_indic, indic_list},
		{"yellow", table_nornori_header_potential, potential_list}, 
		{"green", table_nornori_header_subjunctive, subjunctive_list}, 
		{"orange", table_nornori_header_imperative, imperative_list}, 
	}
	
	--case-by-case data
	if type == "nornori-jariatu" then
		indic_list = wcod_tense_3
		indic_list = wcod_tense_3
		indic_list = wcod_tense_3
	elseif type == "nornori-ibili" then
		show_arch = true
		--indicative
		indic_list = 1
		indic_list = 1
		indic_list = 2
		indic_list = "potential present"
		--potential
		potential_list = 1
		potential_list = 2
		potential_list = "indicative hypothetic consequence"
		potential_list = 2
		potential_list = "indicative past consequence"
		potential_list = 1
		potential_list = 2
		potential_list = "indicative conditional"
		--subjunctive and imperative
		subjunctive_list = 1
		subjunctive_list = 2
		subjunctive_list = "indicative past"
		imperative_list = wcod_tense_23
	elseif type == "nornori-izan" then
		show_arch = true
		--indicative
		indic_list = 1
		indic_list = 1
		indic_list = 0
		--potential
		potential_list = 1
		potential_list = 1
		potential_list = 1
		potential_list = 1
		potential_list = 1
		--subjunctive and imperative
		subjunctive_list = 3
		subjunctive_list = {"subpres", "subpresla"}
		subjunctive_list = table_nornori_double
		subjunctive_list = 1
		subjunctive_list = 3
		subjunctive_list = {"subpast", "subpastla"}
		subjunctive_list = table_nornori_double
		imperative_list = wcod_tense_23
	end
	
	----------------
	local function add_notes(row, mood, tense)
		for i, note in ipairs(notes_data) do
			if note == "tense_name" and m_table.listToSet(note) then
				row = rsub(row, "TENSE_NAME", "TENSE_NAME" .. "<sup>" .. tostring(i) .. "</sup>")
			elseif note == "mood_name" and m_table.listToSet(note) then
				row = rsub(row, "MOOD", "MOOD" .. "<sup>" .. tostring(i) .. "</sup>")
			elseif note == "tense_person" then
				for _, tense_person in ipairs(note) do
					if tense == tense_person then
						row = rsub(row, tense_person .. "}}}", tense_person .. "}}}" .. "<sup>" .. tostring(i) .. "</sup>")
					end
				end
			end
		end
		return row
	end
	----------------	
	--generate the code
	code = ""
	for i, mood in ipairs(moods) do
		tensenum = 0
		for _, tense in ipairs(mood) do
			if tense == true then
				tensenum = tensenum + 1
			end
		end
		
		moodheader = mood
		if type == "nornori-izan" then
			moodheader = mw.ustring.gsub(moodheader, "NOTES", "<sup>2</sup>")
		else
			moodheader = mw.ustring.gsub(moodheader, "NOTES", "")
		end
		moodheader = mw.ustring.gsub(moodheader, "COLLAPSED_ROW_NUM", tostring(tensenum*2))
		newmood = moodheader
		
		local expanded_row_num = 0
		for j, tense in ipairs(mood) do
			if tense == true then
				if tense == 1 then
					newtense = m_com.rsub_multiple(tense, {"TENSE_NAME", "TENSE_ABBR"}, {tense, tense})
					expanded_row_num = expanded_row_num + 8
				elseif tense == 0 then
					newtense = m_com.rsub_multiple(wcod_empty_tense, {"TENSE_NAME"}, {tense})
					expanded_row_num = expanded_row_num + 2
				elseif tense == 2 then
					newtense = m_com.rsub_multiple(wcod_same_tense_as, {"TENSE_NAME", "SEE_TENSE"}, {tense, tense})
					expanded_row_num = expanded_row_num + 2
				elseif tense == 3 then
					newtense = m_com.rsub_multiple(tense, {"TENSE_NAME", "TENSE_ABBR2", "TENSE_ABBR1"}, {tense, tense, tense})
					expanded_row_num = expanded_row_num + 8
				end
				newtense = mw.ustring.gsub(newtense, "COLOR", mood)
				newmood = newmood .. newtense
				if j < tensenum then
					newmood = newmood .. table_tense_sep
				end
			end
		end
		newmood = mw.ustring.gsub(newmood, "EXPANDED_ROW_NUM", tostring(expanded_row_num))
		
		code = code .. newmood
		if i < #moods then
			code = code .. table_mood_sep
		end
	end
	
	return code
end

--modular tables
table_nornori_header_indic = [=[
|- class="inflection-table-blue"
! class="vsShow outer" rowspan="COLLAPSED_ROW_NUM" | indicative
! class="vsHide outer" rowspan="EXPANDED_ROW_NUM"  | indicative
]=]

table_nornori_header_potential = [=[
|- class="inflection-table-yellow"
! class="vsShow outer" rowspan="COLLAPSED_ROW_NUM" | potentialNOTES
! class="vsHide outer" rowspan="EXPANDED_ROW_NUM"  | potentialNOTES
]=]

table_nornori_header_subjunctive = [=[
|- class="inflection-table-green"
! class="vsShow outer" rowspan="COLLAPSED_ROW_NUM" | subjunctiveNOTES
! class="vsHide outer" rowspan="EXPANDED_ROW_NUM"  | subjunctiveNOTES
]=]

table_nornori_header_imperative = [=[
|- class="inflection-table-orange"
! class="vsShow outer" rowspan="COLLAPSED_ROW_NUM" | imperativeNOTES
! class="vsHide outer" rowspan="EXPANDED_ROW_NUM"  | imperativeNOTES
]=]

table_tense_sep = [=[
|-
! class="vsHide separator" colspan="11" | 
]=]

table_mood_sep = [=[
|-
! class="separator" colspan="11" | 
]=]

table_nornori_double = [=[
|- class="vsHide inflection-table-COLOR" 
! rowspan="7" | TENSE_NAME
| ―
| {{{TENSE_ABBR1hiniri}}},<br/>{{{TENSE_ABBR2hiniri}}}
| {{{TENSE_ABBR1huraniri}}},<br/>{{{TENSE_ABBR2huraniri}}}
| ―
| {{{TENSE_ABBR1zuniri}}},<br/>{{{TENSE_ABBR2zuniri}}}
| {{{TENSE_ABBR1zuekniri}}},<br/>{{{TENSE_ABBR2zuekniri}}}
| {{{TENSE_ABBR1haiekniri}}},<br/>{{{TENSE_ABBR2haiekniri}}}
| class="secondary" | niri
! class="nowrap" | <abbr title="first-person singular">1st sg</abbr>
|- class="vsHide inflection-table-COLOR" 
| {{{TENSE_ABBR1nihirim}}}{{{TENSE_ABBR1nihirif}}},<br/>{{{TENSE_ABBR2nihirim}}}{{{TENSE_ABBR2nihirif}}}
| ―
| {{{TENSE_ABBR1hurahirim}}}{{{TENSE_ABBR1hurahirif}}},<br/>{{{TENSE_ABBR2hurahirim}}}{{{TENSE_ABBR2hurahirif}}}
| {{{TENSE_ABBR1guhirim}}}{{{TENSE_ABBR1guhirif}}},<br/>{{{TENSE_ABBR2guhirim}}}{{{TENSE_ABBR2guhirif}}}
| ―
| ―
| {{{TENSE_ABBR1haiekhirim}}}{{{TENSE_ABBR1haiekhirif}}},<br/>{{{TENSE_ABBR2haiekhirim}}}{{{TENSE_ABBR2haiekhirif}}}
| class="secondary" | hiri
! class="nowrap" | <abbr title="second-person singular informal">2nd sg inf.</abbr>
|- class="inflection-table-COLOR" 
! class="vsShow" | TENSE_NAME
| {{{TENSE_ABBR1nihari}}},<br/>{{{TENSE_ABBR2nihari}}}
| {{{TENSE_ABBR1hihari}}},<br/>{{{TENSE_ABBR2hihari}}}
| {{{TENSE_ABBR1hurahari}}},<br/>{{{TENSE_ABBR2hurahari}}}
| {{{TENSE_ABBR1guhari}}},<br/>{{{TENSE_ABBR2guhari}}}
| {{{TENSE_ABBR1zuhari}}},<br/>{{{TENSE_ABBR2zuhari}}}
| {{{TENSE_ABBR1zuekhari}}},<br/>{{{TENSE_ABBR2zuekhari}}}
| {{{TENSE_ABBR1haiekhari}}},<br/>{{{TENSE_ABBR2haiekhari}}}
| class="secondary" | hari
! class="nowrap" | <abbr title="third-person singular">3rd sg</abbr>
|- class="vsHide inflection-table-COLOR" 
| ―
| {{{TENSE_ABBR1higuri}}},<br/>{{{TENSE_ABBR2higuri}}}
| {{{TENSE_ABBR1huraguri}}},<br/>{{{TENSE_ABBR2huraguri}}}
| ―
| {{{TENSE_ABBR1zuguri}}},<br/>{{{TENSE_ABBR2zuguri}}}
| {{{TENSE_ABBR1zuekguri}}},<br/>{{{TENSE_ABBR2zuekguri}}}
| {{{TENSE_ABBR1haiekguri}}},<br/>{{{TENSE_ABBR2haiekguri}}}
| class="secondary" | guri
! class="nowrap" | <abbr title="first-person plural">1st pl</abbr>
|- class="vsHide inflection-table-COLOR" 
| {{{TENSE_ABBR1nizuri}}},<br/>{{{TENSE_ABBR2nizuri}}}
| ―
| {{{TENSE_ABBR1hurazuri}}},<br/>{{{TENSE_ABBR2hurazuri}}}
| {{{TENSE_ABBR1guzuri}}},<br/>{{{TENSE_ABBR2guzuri}}}
| ―
| ―
| {{{TENSE_ABBR1haiekzuri}}},<br/>{{{TENSE_ABBR2haiekzuri}}}
| class="secondary" | zuri
! class="nowrap" | <abbr title="seTENSE_ABBR1-person singular">2nd sg</abbr>
|- class="vsHide inflection-table-COLOR" 
| {{{TENSE_ABBR1nizuei}}},<br/>{{{TENSE_ABBR2nizuei}}}
| ―
| {{{TENSE_ABBR1hurazuei}}},<br/>{{{TENSE_ABBR2hurazuei}}}
| {{{TENSE_ABBR1guzuei}}},<br/>{{{TENSE_ABBR2guzuei}}}
| ―
| ―
| {{{TENSE_ABBR1haiekzuei}}},<br/>{{{TENSE_ABBR2haiekzuei}}}
| class="secondary" | zuei
! class="nowrap" | <abbr title="second-person plural">2nd pl</abbr>
|- class="vsHide inflection-table-COLOR" 
| {{{TENSE_ABBR1nihaiei}}},<br/>{{{TENSE_ABBR2nihaiei}}}
| {{{TENSE_ABBR1hihaiei}}},<br/>{{{TENSE_ABBR2hihaiei}}}
| {{{TENSE_ABBR1hurahaiei}}},<br/>{{{TENSE_ABBR2hurahaiei}}}
| {{{TENSE_ABBR1guhaiei}}},<br/>{{{TENSE_ABBR2guhaiei}}}
| {{{TENSE_ABBR1zuhaiei}}},<br/>{{{TENSE_ABBR2zuhaiei}}}
| {{{TENSE_ABBR1zuekhaiei}}},<br/>{{{TENSE_ABBR2zuekhaiei}}}
| {{{TENSE_ABBR1haiekhaiei}}},<br/>{{{TENSE_ABBR2haiekhaiei}}}
| class="secondary" | haiei
! class="nowrap" | <abbr title="third-person plural">3rd pl</abbr>
]=]

wcod_empty_tense = [=[
|- class="inflection-table-COLOR"
! TENSE_NAME
| ―
| ―
| ―
| ―
| ―
| ―
| ―
| class="secondary" colspan = "2" | 
]=]

wcod_same_tense_as = [=[
|- class="inflection-table-COLOR"
! TENSE_NAME
| class="secondary" colspan="7" | <div class="center">same as SEE_TENSE</div>
| class="secondary" colspan = "2" | 
]=]

return export