Module:User:Espreon/ca-verb-val

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a private module sandbox of Espreon, for their own experimentation. Items in this module may be added and removed at Espreon's discretion; do not rely on this module's stability.


--[=[
    This module contains functions for creating inflection tables for Catalan
    verbs.
    
    Notice:
    The bot [[User:MewBot]] uses this module to automatically create entries
    for verb forms. If you change how this module works, please notify
    the bot owner so the bot can be updated!
]=]--

local m_utilities = require("Module:utilities")
local com = require("Module:ca-common")

local export = {}

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

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
    local conj_type = frame.args[1] or error("Conjugation type has not been specified. Please pass parameter 1 to the module invocation.")
    dialect = frame.args['dialect']
    local args = frame:getParent().args
    PAGENAME = mw.title.getCurrentTitle().text
    NAMESPACE = mw.title.getCurrentTitle().nsText
    
    local forms, title, categories

    -- Set dialect display name
    if dialect == "central" then
    	dialect_name = "Central Catalan"
    elseif dialect == "valencian" then
    	dialect_name = "Valencian"
    elseif dialect == "algherese" then
    	dialect_name = "Algherese"
    	
    -- If "dialect" doesn't get set/set correctly, assume Central Catalan
    else
    	dialect_name = "Central Catalan"
    	dialect = "central"
    end
    
    if conj_type == "ar" then
        forms, title, categories = conj_1(args)
    elseif conj_type == "re" or conj_type == "er" then
        forms, title, categories = conj_2(args)
    elseif conj_type == "dre" or conj_type == "ure_ïa" then
        forms, title, categories = conj_2_velar(args)
    elseif conj_type == "ir_eix" then
        forms, title, categories = conj_3(args, true)
    elseif conj_type == "ir_no_eix" then
        forms, title, categories = conj_3(args, false)
    else
        error("Unknown conjugation type '" .. conj_type .. "'")
    end
    
    if args["bot"] or "" ~= "" then
        return make_bot_list(forms, sep ~= "")
    else
        return make_table(forms, title) .. m_utilities.format_categories(categories, lang)
    end
end

-- Conjugate a first conjugation verb (-ar)
function conj_1(args)
    local forms = {}
    local categories = {"Catalan first conjugation verbs"}
    local title = "[[Appendix:Catalan verbs#first conjugation|first conjugation]]"
    
    local stems = {}
    stems.back = args[1] or (NAMESPACE == "User" and "-") or error("The first parameter is missing")
    make_stems(stems, "a")
    
    forms["infinitive"] = stems.back .. "ar"
    forms["pres_part"] = stems.back .. "ant"
    forms["past_part"] = stems.back .. "at"
    
    make_pres_1(forms, stems)
    make_impf(forms, stems, "a")
    make_futr_cond(forms, stems.back .. "a")
    make_pret(forms, stems, "a")
    make_impf_sub(forms, stems, "a")
    
    if dialect == "central" then
    	    make_pres_sub_12(forms, stems, "e")
    elseif dialect == "valencian" then
    	    make_pres_sub_12(forms, stems, "e")
    else
    	    make_pres_sub_12(forms, stems, "e")
    end
    
    -- The verb "donar" gets accents on a few forms,
    -- to distinguish them from the noun "dona".
    if stems.back == "don" then
        forms["pres_ind_2sg"] = "dónes"
        forms["pres_ind_3sg"] = "dóna"
        forms["impr_2sg"] = "dóna"
    end
    
    return forms, title, categories
end

-- Conjugate a second conjugation verb in -re or unstressed -er
function conj_2(args)
    local forms = {}
    local categories = {"Catalan second conjugation verbs"}
    local title = "[[Appendix:Catalan verbs#Regular type|second conjugation]]"
    
    local stems = {}
    stems.front_stressedA = args[1] or (NAMESPACE == "User" and "-") or error("The first parameter is missing")
    stems.front = args[2]; if stems.front == "" then stems.front = nil end
    
    if stems.front then
        title = title .. ", alternative stem when stressed"
        table.insert(categories, "Catalan second conjugation verbs with stem alternations")
    end
    
    make_stems(stems, "e")
    
    if stems.front:find("[cmxs]$") or stems.front:find("ny$") or stems.front:find("rr$") then
        forms["infinitive"] = stems.front_stressedA .. "er"
        make_futr_cond(forms, stems.front .. "e")
    elseif stems.front:find("[ln]$") then
        forms["infinitive"] = stems.back_stressed .. "dre"
        make_futr_cond(forms, stems.back .. "d")
    else
        forms["infinitive"] = stems.back_stressed .. "re"
        make_futr_cond(forms, stems.back)
    end
    
    forms["pres_part"] = stems.front .. "ent"
    forms["past_part"] = stems.back .. "ut"
    
    make_pres_23(forms, stems, "e")
    make_impf(forms, stems, "e")
    make_pret(forms, stems, "e")
    make_impf_sub(forms, stems, "e")

    if dialect == "central" then
        make_pres_sub_12(forms, stems, "e")
    elseif dialect == "valencian" then
        make_pres_sub_12(forms, stems, "a")
	else
        make_pres_sub_12(forms, stems, "e")
    end
    
    local past_part = args["past_part"] or ""
    if past_part ~= "" then
        forms["past_part"] = past_part
        title = title .. ", irregular past participle"
        table.insert(categories, "Catalan second conjugation verbs with irregular past participles")
    end
    
    return forms, title, categories
end

-- Conjugate a second conjugation verb (-re) with velar infix
function conj_2_velar(args)
    local forms = {}
    local categories = {"Catalan second conjugation verbs"}
    local title = "[[Appendix:Catalan verbs#Velar-infix stems|second conjugation with velar infix]]"
    
    local stems = {}
    stems.front_stressedA = args[1] or (NAMESPACE == "User" and "-n") or error("The first parameter is missing")
    stems.front = args[2]; if stems.front == "" then stems.front = nil end
    make_stems(stems, "e")
    
    local velar_stems = {}
    velar_stems.back_stressedA = stems.back_stressedA:gsub("v$", "") .. "g"
    velar_stems.back = stems.back:gsub("v$", "") .. "g"
    make_stems(velar_stems, "e")
    
    if stems.back_stressed:find("[aeiouv]$") then
        forms["infinitive"] = stems.back_stressed:gsub("v$", "") .. "ure"
        make_futr_cond(forms, stems.back:gsub("v$", "") .. "u")
    elseif stems.back_stressed:find("[ln]$") then
        forms["infinitive"] = stems.back_stressed .. "dre"
        make_futr_cond(forms, stems.back .. "d")
    else
        error("Invalid stem")
    end
    
    forms["pres_part"] = stems.front .. "ent"
    forms["past_part"] = velar_stems.back .. "ut"
    
    make_pres_23(forms, stems, "e"); forms["pres_ind_1sg"] = velar_stems.final_stressed
    make_impf(forms, stems, "e")
    make_pret(forms, velar_stems, "e")
    make_impf_sub(forms, velar_stems, "e")

   if dialect == "central" then
    	make_pres_sub_12(forms, velar_stems, "e")
    elseif dialect == "valencian" then
    	make_pres_sub_12(forms, velar_stems, "a")
    else
    	make_pres_sub_12(forms, velar_stems, "e")
    end
    
    local past_part = args["past_part"] or ""
    if past_part ~= "" then
        forms["past_part"] = past_part
        title = title .. ", irregular past participle"
        table.insert(categories, "Catalan second conjugation verbs with irregular past participles")
    end
    
    return forms, title, categories
end

-- Conjugate a third conjugation verb (-ir)
function conj_3(args, eix)
    local forms = {}
    local categories = {"Catalan third conjugation verbs"}
    local title
    
    local stems = {}
    stems.front = args[1] or (NAMESPACE == "User" and "-") or error("The first parameter is missing")
    
    if eix then
        table.insert(categories, "Catalan third conjugation verbs with -eix-")
        title = "[[Appendix:Catalan verbs#With -eix-|third conjugation with -eix- infix]]"

        -- Central Catalan/other: add simplistic -eix- here;
        -- Valencian: delay, the efforts required are more complicated
        if dialect == "central" then
            stems.front_stressedA = stems.front .. "eix"
        elseif dialect == "valencian" then
            inchoative = true
        else
            stems.front_stressedA = stems.front .. "eix"
        end
    else
        table.insert(categories, "Catalan third conjugation verbs without -eix-")
        title = "[[Appendix:Catalan verbs#Without -eix-|third conjugation without -eix- infix]]"
        stems.front_stressedA = args[2]; if stems.front_stressedA == "" then stems.front_stressedA = nil end
        
        if stems.front_stressedA then
            title = title .. ", alternative stem when stressed"
            table.insert(categories, "Catalan third conjugation verbs with stem alternations")
        end
    end
    
    make_stems(stems, "i")
    
    forms["infinitive"] = stems.front .. "ir"
    forms["pres_part"] = stems.front .. "int"
    forms["past_part"] = stems.front_i .. "t"
    
    make_pres_23(forms, stems, "i", eix)
    make_impf(forms, stems, "i")
    make_futr_cond(forms, stems.front .. "i")
    make_pret(forms, stems, "i")
    make_pres_sub_3(forms, stems, "i")
    make_impf_sub(forms, stems, "i")
    
    local past_part = args["past_part"] or ""
    if past_part ~= "" then
        forms["past_part"] = past_part
        title = title .. ", irregular past participle"
        table.insert(categories, "Catalan third conjugation verbs with irregular past participles")
    end
    
    return forms, title, categories
end

-- Create the various base stems that endings are attached to.
function make_stems(stems)
    if stems.back or stems.back_stressedA then
        stems.back_stressedA = stems.back_stressedA or stems.back
        stems.front_stressedA = com.back_to_front(stems.back_stressedA)
        
        stems.back_stressed = com.remove_accents(stems.back_stressedA)
        stems.front_stressed = com.remove_accents(stems.front_stressedA)
        
        stems.back = stems.back or stems.back_stressed
        stems.front = com.back_to_front(stems.back)
    elseif stems.front or stems.front_stressedA then
        stems.front_stressedA = stems.front_stressedA or stems.front
        stems.back_stressedA = com.front_to_back(stems.front_stressedA)
        
        stems.front_stressed = com.remove_accents(stems.front_stressedA)
        stems.back_stressed = com.remove_accents(stems.back_stressedA)
        
        stems.front = stems.front or stems.front_stressed
        stems.back = com.front_to_back(stems.front)
    else
        error("No stems were given.")
    end
    
    -- Does this verb need a diaeresis when endings with -i are attached?
    -- Verbs in -aiar, -eiar etc. lose the final -i of the stem
    -- when another -i is attached.
    local diaeresis = (stems.back:find("[aeiou]$") and not stems.back:find("[aeiou]u$"))
    local diaeresis_stressed = (stems.back_stressed:find("[aeiou]$") and not stems.back_stressed:find("[aeiou]u$"))
    
    stems.front_no_i = stems.front:gsub("([aeiou])i$", "%1")
    stems.front_stressed_no_i = stems.front_stressed:gsub("([aeiou])i$", "%1")
    
    stems.front_i = stems.front_no_i:gsub("ü$", "u") .. (diaeresis and "ï" or "i")
    stems.front_stressed_i = stems.front_stressed_no_i:gsub("ü$", "u") .. (diaeresis_stressed and "ï" or "i")
    
    -- Stems that are used with no following syllable, which have final devoicing.
    if stems.back_stressed:find("s$") or stems.back_stressed:find("[ei]n$") then
        if stems.back_stressedA:find("[aeiou]") then
            stems.final_stressedA = stems.back_stressedA:gsub("ss$", "s")
        else
            stems.final_stressedA = stems.back_stressed:gsub("ss$", "s")
        end
    -- l and r can't stand between a consonant and the end or another consonant,
    -- so an epenthetic vowel is inserted.
    elseif stems.back_stressed:find("[bpdtgc][lr]$") then
        stems.final_stressedA = stems.front_stressed .. "e"
    elseif stems.back_stressed:find("[aeiou][bd]$") then
        stems.final_stressedA = stems.back_stressed:gsub("b$", "p"):gsub("d$", "t")
    -- Final "g" rather than "ig" on stressed stems that end in "i", such as "lli-" of the non-inchoative conjugation of "llegir"
    elseif stems.front_stressed:find("ig$") then
        stems.final_stressedA = stems.back_stressed:gsub("j$", "g")
    else
        stems.final_stressedA = stems.back_stressed:gsub("g$", "c"):gsub("j$", "ig")
    end
    
    stems.final_stressed = com.remove_accents(stems.final_stressedA)
end

-- For first-conjugation verbs
function make_pres_1(forms, stems)
	if dialect == "central" then
		forms["pres_ind_1sg"] = stems.back_stressed .. "o"
	elseif dialect == "valencian" then
	-- TODO: add something for the Northern Valencian -o
		forms["pres_ind_1sg"] = stems.back_stressed .. "e"
	elseif dialect == "algherese" or dialect == "balearic" then
		forms["pres_ind_1sg"] = stems.back_stressed
	end

    forms["pres_ind_2sg"] = stems.front_stressed .. "es"
    forms["pres_ind_3sg"] = stems.back_stressed .. "a"
    if dialect == "balearic" then
    	forms["pres_ind_1pl"] = stems.front .. "am"
    else
    	forms["pres_ind_1pl"] = stems.front .. "em"
    end
    if dialect == "balearic" or dialect == "algherese" then
    	forms["pres_ind_2pl"] = stems.front .. "au"
    else
    	forms["pres_ind_2pl"] = stems.front .. "eu"
    end
    forms["pres_ind_3pl"] = stems.front_stressed .. "en"
    
    forms["impr_2sg"] = forms["pres_ind_3sg"]
    forms["impr_2pl"] = forms["pres_ind_2pl"]
end

-- For second- and third-conjugation verbs
-- Need to specify whether 2 or 3 if working with Algherese
function make_pres_23(forms, stems, vowel, inchoative)
	local theme_vowel
	
	-- TODO: This approach needs to be beaten up
	-- Algherese non-inchoative third conjugation verbs are conjugated with "i" rather than "e"
	if dialect == "algherese" and inchoative == false then
		theme_vowel = vowel
	else
		theme_vowel = "e"
	end

	-- Valencian inchoatives, if we're working on Valencian
	-- ... or generate endless non-inchoative forms, if we're not working on an inchoative
	if dialect == "valencian" and inchoative == true then
     	-- TODO: do something for the Northern Valencian -(e)ix-
       	forms["pres_ind_1sg"] = stems.front_stressed_i .. "sc"
       	forms["pres_ind_3sg"] = stems.front_stressed_i .. "x"
       	stems.front_stressed = stems.front_stressed_i .. "x"
    else
    	-- We cannot have a single line for 3rd person singular since the preferred Valencian inchoative can receive a diaeresis
    	-- ... unlike the Central Catalan equivalent.
    	--- For the non-inchoatives, the orthography reflects the voicelessness of the final consonants, like in "rep" < "rebre", hence the use of "stems.final_stressedA"
    	forms["pres_ind_1sg"] = stems.final_stressedA
    	
    	-- TODO: This may cause problems elsewhere
    	-- Algherese includes a final theme vowel in pure third conjugation verbs
    	if dialect == "algherese" and theme_vowel == "i" then
          	forms["pres_ind_3sg"] = stems.front_stressed_i
    	else
           	forms["pres_ind_3sg"] = stems.final_stressedA
    	end
    end

    forms["pres_ind_3pl"] = stems.front_stressed .. theme_vowel .. "n"
    
    -- The 2nd person singular forms are special because
    -- of the way sounds are combined within...
    forms["pres_ind_2sg"] = stems.final_stressed .. "s"

	-- ... as are the 3rd persons singular forms
	-- Central Catalan has -o  in 1st person singular while most of Valencian has zero
	if dialect == "central" then
        forms["pres_ind_1sg"] = stems.back_stressed .. "o"
        forms["pres_ind_3sg"] = stems.final_stressedA
    end
    
    -- Verbs ending in a sibilant consonant get an epenthetic vowel
    -- in the 2nd person singular.
    if stems.front_stressed:find("[cgsx]$") then
        forms["pres_ind_2sg"] = stems.front_stressed .. theme_vowel .. "s"
    -- Verbs ending in a vowel add -u in some forms.
    elseif stems.back_stressed:find("u$") then
        forms["pres_ind_2sg"] = stems.front_stressed .. "us"
        forms["pres_ind_3sg"] = stems.front_stressed .. "u"
    elseif stems.back_stressed:find("[aeiov]$") then
        forms["pres_ind_2sg"] = stems.front_stressed:gsub("v$", "") .. "us"
        forms["pres_ind_3sg"] = stems.front_stressed:gsub("v$", "") .. "u"
        forms["pres_ind_3pl"] = stems.front_stressed:gsub("v$", "") .. "uen"
    end
    
    if vowel == "i" then
        forms["pres_ind_1pl"] = stems.front_i .. "m"
        forms["pres_ind_2pl"] = stems.front_i .. "u"
    else
        forms["pres_ind_1pl"] = stems.front .. theme_vowel .. "m"
        forms["pres_ind_2pl"] = stems.front .. theme_vowel .. "u"
    end
    
    forms["impr_2sg"] = forms["pres_ind_3sg"]
    forms["impr_2pl"] = forms["pres_ind_2pl"]
end

function make_impf(forms, stems, vowel)
    local stem = stems.back .. "av"
    local stemA = stems.back .. "àv"
    
    if vowel ~= "a" then
    	if dialect == "algherese" then
			stem = stems.front_i .. "v"
			stemA = stems.front .. "ív"
		else
	        stem = stems.front_i
	        stemA = stems.front .. "í"
	   end
    end
    
    forms["impf_ind_1sg"] = stem .. "a"
    forms["impf_ind_2sg"] = stem .. "es"
    forms["impf_ind_3sg"] = stem .. "a"
    forms["impf_ind_1pl"] = stemA .. "em"
    forms["impf_ind_2pl"] = stemA .. "eu"
    forms["impf_ind_3pl"] = stem .. "en"
end

function make_pret(forms, stems, vowel)
    local stem = stems.back .. "a"
    local stemA = stems.back .. "à"
    
    if vowel == "e" then
        stem = stems.front .. "e"
        stemA = stems.front .. "é"
    elseif vowel == "i" then
        stem = stems.front_i
        stemA = stems.front .. "í"
    end

    forms["pret_ind_1sg"] = stems.front_no_i .. "í"
    forms["pret_ind_2sg"] = stem .. "res"
    forms["pret_ind_3sg"] = stemA
    forms["pret_ind_1pl"] = stemA .. "rem"
    forms["pret_ind_2pl"] = stemA .. "reu"
    forms["pret_ind_3pl"] = stem .. "ren"

    -- Valencian: generate -r imperfect subjunctives, which are morphologically similar to the synthetic preterites
    if dialect == "valencian" then
        forms["impf_r_sub_2sg"] = forms["pret_ind_2sg"]
        forms["impf_r_sub_1pl"] = forms["pret_ind_1pl"]
        forms["impf_r_sub_2pl"] = forms["pret_ind_2pl"]
        forms["impf_r_sub_3pl"] = forms["pret_ind_3pl"]

        forms["impf_r_sub_1sg"] = stem .. "ra"
        forms["impf_r_sub_3sg"] = stem .. "ra"
    end
end

function make_futr_cond(forms, stem)
    forms["futr_ind_1sg"] = stem .. "ré"
    forms["futr_ind_2sg"] = stem .. "ràs"
    forms["futr_ind_3sg"] = stem .. "rà"
    forms["futr_ind_1pl"] = stem .. "rem"
    forms["futr_ind_2pl"] = stem .. "reu"
    forms["futr_ind_3pl"] = stem .. "ran"
    
    if dialect == "algherese" then
	    forms["cond_1sg"] = stem .. "riva"
	    forms["cond_2sg"] = stem .. "rives"
	    forms["cond_3sg"] = stem .. "riva"
	    forms["cond_1pl"] = stem .. "rívem"
	    forms["cond_2pl"] = stem .. "ríveu"
	    forms["cond_3pl"] = stem .. "riven"
    else
	    forms["cond_1sg"] = stem .. "ria"
	    forms["cond_2sg"] = stem .. "ries"
	    forms["cond_3sg"] = stem .. "ria"
	    forms["cond_1pl"] = stem .. "ríem"
	    forms["cond_2pl"] = stem .. "ríeu"
	    forms["cond_3pl"] = stem .. "rien"
    end
end

function make_pres_sub_12(forms, stems, vowel)
	if dialect == "central" or dialect == "balearic" or dialect == "algherese" then
        forms["pres_sub_1sg"] = stems.front_stressed_i
        forms["pres_sub_2sg"] = stems.front_stressed_i .. "s"
        forms["pres_sub_3sg"] = stems.front_stressed_i
    
        if vowel == "i" then
                forms["pres_sub_1pl"] = stems.front_i .. "m"
                forms["pres_sub_2pl"] = stems.front_i .. "u"
        else
                forms["pres_sub_1pl"] = stems.front .. "em"
                forms["pres_sub_2pl"] = stems.front .. "eu"
    end
    forms["pres_sub_3pl"] = stems.front_stressed_i .. "n"

    elseif dialect == "valencian" then
            forms["pres_sub_1sg"] = stems.back_stressed .. vowel
            forms["pres_sub_2sg"] = stems.front_stressed .. "es"
            forms["pres_sub_3sg"] = stems.back_stressed .. vowel
    
            forms["pres_sub_1pl"] = stems.front .. "em"
            forms["pres_sub_2pl"] = stems.front .. "eu"
    
            forms["pres_sub_3pl"] = stems.front_stressed .. "en"
    end

    forms["impr_3sg"] = forms["pres_sub_3sg"]
    forms["impr_1pl"] = forms["pres_sub_1pl"]
    -- Suppress in Algherese, as it does not have "vostès"
    if dialect ~= "algherese" then
	    forms["impr_3pl"] = forms["pres_sub_3pl"]
	else
		forms["impr_3pl"] = "&mdash;"
	end
end

-- For third-conjugation verbs
function make_pres_sub_3(forms, stems, vowel)
	-- Valencian: add inchoatives along with endings if the verb is inchoative
	if dialect == "valencian" then
        if inchoative == true then
            forms["pres_sub_1sg"] = stems.front_stressed_i .. "sca"
            forms["pres_sub_2sg"] = stems.front_stressed_i .. "sques"
            forms["pres_sub_3sg"] = stems.front_stressed_i .. "sca"
            forms["pres_sub_3pl"] = stems.front_stressed_i .. "squen"
        -- Not inchoative; just add the endings
        else
            forms["pres_sub_1sg"] = stems.back_stressed .. "a"
            forms["pres_sub_2sg"] = stems.front_stressed .. "es"
            forms["pres_sub_3sg"] = stems.back_stressed .. "a"
            forms["pres_sub_3pl"] = stems.front_stressed .. "en"
        end
	elseif dialect == "central" or dialect == "balearic" or dialect == "algherese" then
            forms["pres_sub_1sg"] = stems.front_stressed_i
            forms["pres_sub_2sg"] = stems.front_stressed_i .. "s"
            forms["pres_sub_3sg"] = stems.front_stressed_i
            forms["pres_sub_3pl"] = stems.front_stressed_i .. "n"
	end	
    
    if vowel == "i" then
        forms["pres_sub_1pl"] = stems.front_i .. "m"
        forms["pres_sub_2pl"] = stems.front_i .. "u"
    else
        forms["pres_sub_1pl"] = stems.front .. "em"
        forms["pres_sub_2pl"] = stems.front .. "eu"
    end
    
    forms["impr_3sg"] = forms["pres_sub_3sg"]
    forms["impr_1pl"] = forms["pres_sub_1pl"]
    -- Suppress in Algherese, as it does not have "vostès"
    if dialect ~= "algherese" then
	    forms["impr_3pl"] = forms["pres_sub_3pl"]
	else
		forms["impr_3pl"] = "&mdash;"
	end
end

function make_impf_sub(forms, stems, vowel)
    local stem = stems.front .. "e"
    local stemA = stems.front .. "é"
    
    if vowel == "i" then
        stem = stems.front_i
        stemA = stems.front .. "í"
    end

	if dialect == "algherese" then
	    forms["impf_sub_1sg"] = stem .. "ssi"
	    forms["impf_sub_3sg"] = stem .. "ssi"
    else
	    forms["impf_sub_1sg"] = stemA .. "s"
	    forms["impf_sub_3sg"] = stemA .. "s"
    end

	if dialect == "central" or dialect == "balearic" or dialect == "algherese" then
        forms["impf_sub_2sg"] = stem .. "ssis"
        forms["impf_sub_1pl"] = stemA .. "ssim"
        forms["impf_sub_2pl"] = stemA .. "ssiu"
        forms["impf_sub_3pl"] = stem .. "ssin"
    elseif dialect == "valencian" then
        forms["impf_sub_2sg"] = stem .. "sses"
        forms["impf_sub_1pl"] = stemA .. "ssem"
        forms["impf_sub_2pl"] = stemA .. "sseu"
        forms["impf_sub_3pl"] = stem .. "ssen"
    end
end

-- Make the table
function make_table(forms, title)
    -- Make links out of all forms
    for key, form in pairs(forms) do
    	if forms[key] ~= "&mdash;" then
        	forms[key] = com.link_form(form)
        end
    end
    
    local pronouns = {}
    local impf_sub_row, pret_ind_row, indicative_rows

	-- Start setting varying pronoun labels
	-- First, set defaults
	pronouns["ind_subj_1pl"] = "nosaltres<br />nós"
	pronouns["imp_1pl"] = "nosaltres"
	pronouns["2pl"] = "vosaltres<br />vós"
   	pronouns["ind_subj_3sg"] = "ell/ella<br />vostè"
	pronouns["ind_subj_3pl"] = "ells/elles<br />vostès"
	pronouns["imp_3sg"] = "vostè"
	pronouns["imp_3pl"] = "vostès"

    if dialect == "valencian" then
    	pronouns["ind_subj_3sg"] = "ell/ella<br />vosté"
    	pronouns["ind_subj_3pl"] = "ells/elles<br />vostés"
    	pronouns["imp_3sg"] = "vosté"
    	pronouns["imp_3pl"] = "vostés"
    elseif dialect == "algherese" then
    	pronouns["ind_subj_1pl"] = "nosaltros<br />nós"
    	pronouns["imp_1pl"] = "nosaltros"
    	pronouns["2pl"] = "vosaltros<br />vós"
    	-- Aside from "ellos" rather than "ells", Algherese does not have "vostès"
    	pronouns["ind_subj_3pl"] = "ellos/elles<br />&mdash;"
    	pronouns["imp_3pl"] = "&mdash;"
    end
    
    -- Shape imperfect subjunctive row
    if dialect == "valencian" then
    	impf_sub_row = [=[
    		|-
    		! style="height:3em;background:#c0e4c0;" rowspan="1" | imperfect
    		| style=";" | ]=] .. forms["impf_r_sub_1sg"] .. [=[<br /> ]=] .. forms["impf_sub_1sg"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_r_sub_2sg"] ..  [=[<br /> ]=] .. forms["impf_sub_2sg"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_r_sub_3sg"] .. [=[<br /> ]=] .. forms["impf_sub_3sg"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_r_sub_1pl"] .. [=[<br /> ]=] .. forms["impf_sub_1pl"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_r_sub_2pl"] .. [=[<br /> ]=] .. forms["impf_sub_2pl"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_r_sub_3pl"] .. [=[<br /> ]=] .. forms["impf_sub_3pl"] .. [=[
    		]=]
    else
	
	impf_sub_row = [=[
    		|-
    		! style="height:3em;background:#c0e4c0;" rowspan="1" | imperfect
    		| style=";" | ]=] .. forms["impf_sub_1sg"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_sub_2sg"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_sub_3sg"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_sub_1pl"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_sub_2pl"] .. [=[
    		
    		| style=";" | ]=] .. forms["impf_sub_3pl"] .. [=[
    		]=]
    end

	-- Form preterite row/lack thereof - these forms do not exist in Algherese
	if dialect ~= "algherese" then
		pret_ind_row = [=[
			|-
			! style="height:3em;background:#c0cfe4;" | preterite
			| style=";" | ]=] .. forms["pret_ind_1sg"] .. [=[
			
			| style=";" | ]=] .. forms["pret_ind_2sg"] .. [=[
			
			| style=";" | ]=] .. forms["pret_ind_3sg"] .. [=[
			
			| style=";" | ]=] .. forms["pret_ind_1pl"] .. [=[
			
			| style=";" | ]=] .. forms["pret_ind_2pl"] .. [=[
			
			| style=";" | ]=] .. forms["pret_ind_3pl"] .. [=[
			]=]
		indicative_rows = 6
	else
		pret_ind_row = ""	
		indicative_rows = 5
	end
    
    return [=[
<div class="NavFrame">
<div class="NavHead" style="text-align: left">(]=] .. dialect_name ..[=[) Conjugation of '']=] .. forms["infinitive"] .. "''" .. (title and " (" .. title .. ")" or "") .. [=[</div>
<div class="NavContent">
{| style="width:100%;background:#F0F0F0;;padding:.3em"
|-
! colspan="3" style="background:#e2e4c0;" | infinitive
| colspan="5" style=";"| ]=] .. forms["infinitive"] .. [=[

|-
! colspan="3" style="background:#e2e4c0;" | present participle
| colspan="5" style=";"| ]=] .. forms["pres_part"] .. [=[

|-
! colspan="3" style="background:#e2e4c0;" | past participle
| colspan="5" style=";"| ]=] .. forms["past_part"] .. [=[

|-
! colspan="2" rowspan="2" style="background:#e2e4cb;" | person
! colspan="3" style="background:#e2e4cb;" | singular
! colspan="3" style="background:#e2e4cb;" | plural
|-
! style="background:#e2e4cb;;width:12.5%" | first
! style="background:#e2e4cb;;width:12.5%" | second
! style="background:#e2e4cb;;width:12.5%" | third
! style="background:#e2e4cb;;width:12.5%" | first
! style="background:#e2e4cb;;width:12.5%" | second
! style="background:#e2e4cb;;width:12.5%" | third
|-
! rowspan=" ]=] .. indicative_rows .. '"' .. [=[ '' style="background:#c0cfe4;" | indicative
! style="background:#c0cfe4;" | 
! style="background:#c0cfe4;" | jo
! style="background:#c0cfe4;" | tu
! style="background:#c0cfe4;" | ]=] .. pronouns["ind_subj_3sg"] .. [=[

! style="background:#c0cfe4;" | ]=] .. pronouns["ind_subj_1pl"] .. [=[

! style="background:#c0cfe4;" | ]=] .. pronouns["2pl"] .. [=[

! style="background:#c0cfe4;" | ]=] .. pronouns["ind_subj_3pl"] .. [=[

|-
! style="height:3em;background:#c0cfe4;" | present
| style=";" | ]=] .. forms["pres_ind_1sg"] .. [=[

| style=";" | ]=] .. forms["pres_ind_2sg"] .. [=[

| style=";" | ]=] .. forms["pres_ind_3sg"] .. [=[

| style=";" | ]=] .. forms["pres_ind_1pl"] .. [=[

| style=";" | ]=] .. forms["pres_ind_2pl"] .. [=[

| style=";" | ]=] .. forms["pres_ind_3pl"] .. [=[

|-
! style="height:3em;background:#c0cfe4;" | imperfect
| style=";" | ]=] .. forms["impf_ind_1sg"] .. [=[

| style=";" | ]=] .. forms["impf_ind_2sg"] .. [=[

| style=";" | ]=] .. forms["impf_ind_3sg"] .. [=[

| style=";" | ]=] .. forms["impf_ind_1pl"] .. [=[

| style=";" | ]=] .. forms["impf_ind_2pl"] .. [=[

| style=";" | ]=] .. forms["impf_ind_3pl"] .. [=[

|-
! style="height:3em;background:#c0cfe4;" | future
| style=";" | ]=] .. forms["futr_ind_1sg"] .. [=[

| style=";" | ]=] .. forms["futr_ind_2sg"] .. [=[

| style=";" | ]=] .. forms["futr_ind_3sg"] .. [=[

| style=";" | ]=] .. forms["futr_ind_1pl"] .. [=[

| style=";" | ]=] .. forms["futr_ind_2pl"] .. [=[

| style=";" | ]=] .. forms["futr_ind_3pl"] .. [=[

]=] .. pret_ind_row .. [=[

|-
! style="height:3em;background:#c0cfe4;" | conditional
| style=";" | ]=] .. forms["cond_1sg"] .. [=[

| style=";" | ]=] .. forms["cond_2sg"] .. [=[

| style=";" | ]=] .. forms["cond_3sg"] .. [=[

| style=";" | ]=] .. forms["cond_1pl"] .. [=[

| style=";" | ]=] .. forms["cond_2pl"] .. [=[

| style=";" | ]=] .. forms["cond_3pl"] .. [=[

|-
! style="background:#c0e4c0;" rowspan="3" | subjunctive
! style="background:#c0e4c0;" |
! style="background:#c0e4c0;" | jo
! style="background:#c0e4c0;" | tu
! style="background:#c0e4c0;" | ]=] .. pronouns["ind_subj_3sg"] .. [=[

! style="background:#c0e4c0;" | ]=] .. pronouns["ind_subj_1pl"] .. [=[

! style="background:#c0e4c0;" | ]=] .. pronouns["2pl"] .. [=[

! style="background:#c0e4c0;" | ]=] .. pronouns["ind_subj_3pl"] .. [=[

|-
! style="height:3em;background:#c0e4c0;" | present
| style=";" | ]=] .. forms["pres_sub_1sg"] .. [=[

| style=";" | ]=] .. forms["pres_sub_2sg"] .. [=[

| style=";" | ]=] .. forms["pres_sub_3sg"] .. [=[

| style=";" | ]=] .. forms["pres_sub_1pl"] .. [=[

| style=";" | ]=] .. forms["pres_sub_2pl"] .. [=[

| style=";" | ]=] .. forms["pres_sub_3pl"] .. [=[


]=] .. impf_sub_row .. [=[


|-
! colspan="2" rowspan="2" style="height:3em;background:#e4d4c0;" | imperative
! style="background:#e4d4c0;" | &mdash;
! style="background:#e4d4c0;" | tu
! style="background:#e4d4c0;" | ]=] .. pronouns["imp_3sg"] .. [=[

! style="background:#e4d4c0;" | ]=] .. pronouns["imp_1pl"] .. [=[

! style="background:#e4d4c0;" | ]=] .. pronouns["2pl"] .. [=[

! style="background:#e4d4c0;" | ]=] .. pronouns["imp_3pl"] .. [=[

|-
| &mdash;
| style=";" | ]=] .. forms["impr_2sg"] .. [=[

| style=";" | ]=] .. forms["impr_3sg"] .. [=[

| style=";" | ]=] .. forms["impr_1pl"] .. [=[

| style=";" | ]=] .. forms["impr_2pl"] .. [=[

| style=";" | ]=] .. forms["impr_3pl"] .. [=[

|}</div></div>]=]
end

-- This generates machine-readable output, which allows formbots to easily
-- parse the output of the module.
function make_bot_list(forms)
    local ret = ""
    
    for key, form in pairs(forms) do
        ret = ret .. "* " .. key .. "=" .. form .. "\n"
    end
    
    return ret
end

return export