Jump to content

Module:sk-verb

From Wiktionary, the free dictionary


--[=[
    This module contains functions for creating inflection tables for Slovak
    verbs.
]=]--

local export = {}

-- Within this module, conjugations are the functions that do the actual
-- conjugating by creating the forms of a basic verb.
-- They are defined further down.
local conjugations = {}
local lang = require("Module:languages").getByCode("sk")
local m_links = require("Module:links")

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
    local args = frame:getParent().args
    NAMESPACE = mw.title.getCurrentTitle().nsText
    if NAMESPACE == "" then
    	PAGENAME = mw.title.getCurrentTitle().text
    else
    	if args["pagename"] then
    		PAGENAME = args["pagename"]
    	else
    		error("Pagename not specified")
    	end
    end
 
    -- Default to impf on the template page so that there is no script error.
    local verb_type = args[1] or (NAMESPACE == "Template" and "impf") or error("Verb type has not been specified. Please pass parameter 1")
    local conj_type = args[2] or error("Conjugation type has not been specified. Please pass parameter 2")
    
    --reflexive
    local refl = false
    if mw.ustring.find(verb_type, "s[ai]") then
    	refl = true
    	PAGENAME = PAGENAME .. " " .. mw.ustring.match(verb_type, "s[ai]")
    elseif mw.ustring.find(PAGENAME, " s[ai]$") then
    	refl = true
    end
    --perfective
    local perf = false
    if not mw.ustring.find(verb_type, "impf") then perf = true end
    --impersonal
    local impers = false
    if mw.ustring.find(verb_type, "impers") then impers = true end
    
    local cats = {
    	refl = refl,
    	perf = perf,
    	impers = impers
    }
    
    PERF_FULL = "perfective"
    if not perf then PERF_FULL = "imperfective" end 
    
    IMPERS = ""
    if impers then IMPERS = "impersonal; " end
    
    local forms, title, categories
 
    if conjugations[conj_type] then
        forms, title, categories = conjugations[conj_type](args)
    else
        error("Unknown conjugation type '" .. conj_type .. "'")
    end
 
    --alternative forms
    forms["impr_2sg2"] = args["impr_2sg2"]
    forms["impr_1pl2"] = args["impr_1pl2"]
    forms["impr_2pl2"] = args["impr_2pl2"]
    forms["pres_actv_part2"] = args["pres_actv_part2"]
    forms["past_actv_part2"] = args["past_actv_part2"]
    forms["pres_pasv_part2"] = args["pres_pasv_part2"]
    forms["transgr2"] = args["transgr2"]
    forms["gerund2"] = args["gerund2"]
    forms["past_m2"] = args["past_m2"]
    forms["past_f2"] = args["past_f2"]
    forms["past_n2"] = args["past_n2"]
    forms["past_pl2"] = args["past_pl2"]
    forms["pres_futr_1sg2"] = args["pres_futr_1sg2"]
    forms["pres_futr_2sg2"] = args["pres_futr_2sg2"]
    forms["pres_futr_3sg2"] = args["pres_futr_3sg2"]
    forms["pres_futr_1pl2"] = args["pres_futr_1pl2"]
    forms["pres_futr_2pl2"] = args["pres_futr_2pl2"]
    forms["pres_futr_3pl2"] = args["pres_futr_3pl2"]
    
    if args["gerund"] then forms["gerund"] = args["gerund"] end
    if args["pres_pasv_part"] then forms["pres_pasv_part"] = args["pres_pasv_part"] end
    
    --parameters passed by the user
    local no_impr = args["no_impr"]
    local no_pasv_part = args["no_pasv_part"]
    local no_gerund = args["no_gerund"]
    local pasv_part = args["pasv_part"]
    
    local params = {
    	no_impr = no_impr,
    	no_pasv_part = no_pasv_part,
    	no_gerund = no_gerund,
    	pasv_part = pasv_part
    }
 
    -- Perfective/imperfective
    table.insert(categories, "Slovak " .. PERF_FULL .. " verbs")
 
    -- Reflexive
    if refl then
        make_reflexive(forms)
        table.insert(categories, "Slovak reflexive verbs")
    end
 
    -- Impersonal
    if impers then
        table.insert(categories, "Slovak impersonal verbs")
    end
 
    local ret = ""
 
    if NAMESPACE == "" then
        local sort_key = PAGENAME
        for key, cat in ipairs(categories) do
            ret = ret .. "[[Category:" .. cat .. "|" .. sort_key .. "]]"
        end
    end
 
    return make_table(forms, title, cats, params) .. ret
end

--[=[
    Conjugation functions
]=]--

-- pattern chyt-á-m, chyt-aj-ú, chyt-a-ť
conjugations["1"] = function()
    local forms = {}
    local categories = {"Slovak class 1 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class I, pattern ''chytať'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ať")
    local pres_stem1 = stem
    if last_syllable_long(stem) or mw.ustring.find(stem, "av$") then
    	pres_stem1 = stem .. "a"
    else
    	if mw.ustring.find(stem, "[ňľšcčz]$") or mw.ustring.find(stem, "dz$") or mw.ustring.find(stem, "mer$") or mw.ustring.find(stem, "večer$")
    	or mw.ustring.find(stem, "stav$") then
    		pres_stem1 = stem .. "ia"
    	else
    		pres_stem1 = stem .. "á"
    	end
    end
    local pres_stem2 = stem .. "aj"
    local inf_stem = stem .. "a"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
    
    return forms, title, categories
end

-- pattern rozum-ie-m, rozum-ej-ú, rozum-ie-ť
conjugations["2"] = function()
    local forms = {}
    local categories = {"Slovak class 2 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class II, pattern ''rozumieť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ieť")
    local pres_stem1 = stem .. "ie"
    local pres_stem2 = stem .. "ej"
    local inf_stem = stem .. "e"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
    
    return forms, title, categories
end

-- pattern nes-ie-m, nes-ú, nies-ť
conjugations["3a"] = function(args)
    local forms = {}
    local categories = {"Slovak class 3 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class III, pattern ''niesť'')"

    local alternations = {
        s = {
            t = {"ť", "t"},
            d = {"ď", "d"},
            s = {"s", "s"}
        },
        c = {
            cj = {"č", "k"},
            zj = {"ž", "h"}
        },
        z = {
            zj = {"ž", "h"},
            z = {"z", "z"}
        }
    }
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ť")
    local pres_stem2 = args[3] or (NAMESPACE == "Template" and "-") or error("The 3rd person pl. without the suffix has not been specified. Please pass parameter 3")

    local stem_last = get_last_char(stem)
    local pres_stem_last = get_last_char(pres_stem2)

    local pres_stem1_0 = remove_last_char(pres_stem2) .. alternations[stem_last][remove_diacritics(pres_stem_last)][1]
    local pres_stem1 = pres_stem1_0 .. "ie"
    local inf_stem = remove_last_char(stem) .. alternations[stem_last][remove_diacritics(pres_stem_last)][2]
    if mw.ustring.find(stem, "rás$") then inf_stem = remove_last_char(stem) .. "st" end
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, pres_stem1_0)
    set_participles_etc(forms, nil, pres_stem1_0, "en")
    add_preterite_suffixes(forms, inf_stem)
    
    return forms, title, categories
end

conjugations["3b"] = function()
 
    local forms = {}
    local categories = {"Slovak class 3 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class III, pattern ''trieť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ieť")
    if mw.ustring.find(stem, "[dtnl]$") then
        stem = soften_last_consonant(stem)
    end
    
    local pres_stem1 = stem .. "ie"
    local pres_stem2 = stem
    
    if mw.ustring.find(stem, "mľ$") then
    	pres_stem1 = remove_suffix(stem, "ľ") .. "eľie"
    	pres_stem2 = remove_suffix(stem, "ľ") .. "eľ"
    end
    local inf_stem = stem .. "e"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
    
    
    return forms, title, categories
end

conjugations["3c"] = function()
    local forms = {}
    local categories = {"Slovak class 3 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class III, pattern ''hynúť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "úť")
    local pres_stem1 = soften_last_consonant(stem) .. "ie"
    local pres_stem2 = stem
    local inf_stem = stem .. "u"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, soften_last_consonant(pres_stem2))
    set_participles_etc(forms, inf_stem, inf_stem, "t")
    add_preterite_suffixes(forms, inf_stem)
    
    return forms, title, categories
end

conjugations["3d"] = function()
    local forms = {}
    local categories = {"Slovak class 3 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class III, pattern ''brať'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ať")
    local stem2 = nil
    if mw.ustring.find(stem, "or$") then
        stem2 = stem
    elseif mw.ustring.find(stem, "hn$") then
        stem2 = "žen"
    else
        stem2 = remove_last_char(stem) .. "e" .. get_last_char(stem)
    end
    local pres_stem1 = soften_last_consonant(stem2) .. "ie"
    local pres_stem2 = stem2
    local inf_stem = stem .. "a"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, soften_last_consonant(pres_stem2))
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end

conjugations["4a"] = function()
    local forms = {}
    local categories = {"Slovak class 4 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class IV, pattern ''česať'')"

    local alternations = {
        t = "c",
        d = "dz",
        k = "č",
        c = "č",
        dz = "dž",
        s = "š",
        z = "ž",
        ch = "š",
        h = "ž",
        sl = "šl"
    }
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ať")

    local stem_last = get_last_char(stem)
    if stem_last == "z" or stem_last == "h" or stem_last == "l" then
        local stem_last_two = mw.ustring.sub(stem, -2, -1)
        if stem_last_two == "dz" or stem_last_two == "ch" or stem_last_two == "sl" then
            stem_last = stem_last_two
        end
    end

    local stem2 = stem
    if alternations[stem_last] then
        stem2 = remove_suffix(stem, stem_last) .. alternations[stem_last]
    end

    local pres_stem1 = soften_last_given_consonant(stem2, "nl") .. "e"
    local pres_stem2 = stem2
    local inf_stem = stem .. "a"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, soften_last_given_consonant(pres_stem2, "nl"))
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end

conjugations["4b"] = function()
    local forms = {}
    local categories = {"Slovak class 4 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class IV, pattern ''žať'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ť")
    local vowel_removed = get_last_char(stem)
    stem = remove_reflexive_particle_and_suffix(stem, vowel_removed)

    local stem2 = stem
    local stem_last = get_last_char(stem)
    if stem_last == "j" or stem_last == "ň" then
        if ends_with_2_consonants(stem) then
            stem2 = stem2 .. "í"
        end
        stem2 = stem2 .. "m"
    elseif stem_last == "i" then
        stem = remove_last_char(stem)
        if mw.ustring.find(stem, "vz$") then
            stem2 = "vez"
        end
        stem2 = stem2 .. "m"
    else
        stem2 = stem2 .. "n"
    end

    local pres_stem1 = soften_last_consonant(stem2) .. "e"
    local pres_stem2 = stem2
    local inf_stem = stem .. vowel_removed
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, soften_last_consonant(pres_stem2))
    set_participles_etc(forms, inf_stem, inf_stem, "t")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end

conjugations["4c"] = function()
    local forms = {}
    local categories = {"Slovak class 4 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class IV, pattern ''chudnúť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ť")
    stem = remove_reflexive_particle_and_suffix(stem, get_last_char(stem))

    local pres_stem1 = soften_last_consonant(stem) .. "e"
    local pres_stem2 = stem
    local inf_stem = stem .. "u"
    local inf_stem2 = remove_suffix(stem, "n")
    if mw.ustring.find(stem, "ľn$") or stem == "usn" or stem == "hn" then
    	inf_stem2 = inf_stem2 .. "nu"
    end
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, soften_last_consonant(pres_stem2))
    set_participles_etc(forms, inf_stem, inf_stem, "t")
    add_preterite_suffixes(forms, inf_stem2)
 
    return forms, title, categories
end

conjugations["4d"] = function(args)
    local forms = {}
    local categories = {"Slovak class 4 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class IV, pattern ''žuť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ť")
    local stem2 = stem
    if mw.ustring.find(stem, "i[ae]$") then
        if args[3] then
            stem2 = remove_last_char(args[3])
        else
            stem2 = mw.ustring.sub(stem, 1, -3) .. "e"
        end
    else
    	-- for doublets kovať, žuvať and snovať
    	if args[3] then
            stem2 = args[3]
        end
    end

    local pres_stem1 = stem2 .. "je"
    local pres_stem2 = stem2 .. "j"
    local inf_stem = stem
    if mw.ustring.find(stem, "ie$") then
        inf_stem = stem2
    end
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "t")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end
 
conjugations["4e"] = function()
    local forms = {}
    local categories = {"Slovak class 4 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class IV, pattern ''pracovať'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ovať")

    local pres_stem1 = stem .. "uje"
    local pres_stem2 = stem .. "uj"
    local inf_stem = stem .. "ova"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ú")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end
 
conjugations["5a"] = function()
    local forms = {}
    local categories = {"Slovak class 5 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class V, pattern ''robiť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "iť")
    if mw.ustring.find(stem, "[dtnl]$") then
        stem = soften_last_consonant(stem)
    end

    local pres_stem1 = stem .. "í"
    if last_syllable_long(stem) then
        pres_stem1 = shorten_last_vowel(pres_stem1)
    end
    local pres_stem2 = stem
    local inf_stem = stem .. "i"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ia")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, pres_stem2, "en")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end

conjugations["5b"] = function()
    local forms = {}
    local categories = {"Slovak class 5 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class V, pattern ''vidieť'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ieť")
    if mw.ustring.find(stem, "[dtnl]$") then
        stem = soften_last_consonant(stem)
    end
    local pres_stem1 = stem .. "í"
    local pres_stem2 = stem
    local inf_stem = stem .. "e"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ia")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
 
    return forms, title, categories
end

conjugations["5c"] = function()
    local forms = {}
    local categories = {"Slovak class 5 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class V, pattern ''kričať'')"
    
    local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ať")
    local pres_stem1 = stem .. "í"
    local pres_stem2 = stem
    local inf_stem = stem .. "a"
    
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, pres_stem1, pres_stem2, "ia")
    add_imperative_suffixes(forms, pres_stem2)
    set_participles_etc(forms, inf_stem, inf_stem, "n")
    add_preterite_suffixes(forms, inf_stem)
    
    return forms, title, categories
end

conjugations["irreg-byť"] = function()
    -- irregular, only for verbs derived from byť
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "byť")
 
    forms["infinitive"] = PAGENAME

    forms["pres_futr_1sg"] = prefix .. "som"
    forms["pres_futr_2sg"] = prefix .. "si"
    forms["pres_futr_3sg"] = prefix .. "je"
    forms["pres_futr_1pl"] = prefix .. "sme"
    forms["pres_futr_2pl"] = prefix .. "ste"
    forms["pres_futr_3pl"] = prefix .. "sú"
 
    add_imperative_suffixes(forms, prefix .. "buď")
    set_participles_etc(forms, prefix .. "by", prefix .. "by", "t")
    forms["pres_pasv_part"] = ""
    add_preterite_suffixes(forms, prefix .. "bo")
 
    return forms, title, categories
end

conjugations["irreg-jesť"] = function()
    -- irregular, only for verbs derived from jesť
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "jesť")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "je", prefix .. "jed", "ia")
    add_imperative_suffixes(forms, prefix .. "jedz")
    set_participles_etc(forms, nil, prefix .. "jed", "en")
    forms["past_actv_part"] = ""
    add_preterite_suffixes(forms, prefix .. "jed")
 
    return forms, title, categories
end

conjugations["irreg-vedieť"] = function()
    -- irregular, only for verbs derived from vedieť
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "vedieť")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "vie", prefix .. "ved", "ia")
    if prefix == "" then
        add_imperative_suffixes(forms, "vedz")
    else
        add_imperative_suffixes(forms, prefix .. "veď")
    end
    set_participles_etc(forms, prefix .. "vede", prefix .. "vede", "n")
    add_preterite_suffixes(forms, prefix .. "vede")
 
    return forms, title, categories
end

conjugations["irreg-chcieť"] = function()
    -- irregular, only for verbs derived from chcieť
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "chcieť")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "chce", prefix .. "chc", "ú")
    add_imperative_suffixes(forms, prefix .. "chc")
    set_participles_etc(forms, prefix .. "chce", prefix .. "chce", "n")
    forms["transgr"] = prefix .. "chcejúc"
    forms["pres_actv_part"] = forms["transgr"] .. "i"
    add_preterite_suffixes(forms, prefix .. "chce")
 
    return forms, title, categories
end

conjugations["irreg-ísť"] = function()
    -- irregular, only for verbs derived from ísť
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "sť")
    if prefix == "í" then prefix = "i" end
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "de", prefix .. "d", "ú")
    add_imperative_suffixes(forms, prefix .. "ď")
    set_participles_etc(forms, nil, prefix .. "de", "n")
    local preterite_stem = shorten_last_vowel(remove_suffix(prefix, "j")) .. "š"
    add_preterite_suffixes(forms, preterite_stem)
    forms["past_m"] = preterite_stem .. "iel"
 
    return forms, title, categories
end

conjugations["irreg-stáť"] = function()
    -- irregular, only for verbs derived from stáť or báť sa
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "áť")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "ojí", prefix .. "oj", "ia")
    add_imperative_suffixes(forms, prefix .. "oj")
    set_participles_etc(forms, prefix .. "á", prefix .. "á", "t")
    add_preterite_suffixes(forms, prefix .. "á")
 
    return forms, title, categories
end

conjugations["irreg-stať"] = function()
    -- irregular, only for verbs derived from stať (sa)
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "stať")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "stane", prefix .. "stan", "ú")
    add_imperative_suffixes(forms, prefix .. "staň")
    set_participles_etc(forms, prefix .. "sta", prefix .. "sta", "n")
    add_preterite_suffixes(forms, prefix .. "sta")
 
    return forms, title, categories
end

conjugations["irreg-môcť"] = function(args)
    -- officially regular according to the pattern niesť
    local forms = {}
    local categories = {"Slovak class 3 verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (" .. PERF_FULL .. "; " .. IMPERS .. "class III, pattern ''niesť'')"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "môcť")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "môže", prefix .. "môž", "ú")
    set_participles_etc(forms, nil, prefix .. "može", "n")
    if prefix ~= "" then
        add_imperative_suffixes(forms, prefix .. "môž")
    else
        forms["pres_actv_part"] = ""
        forms["pres_pasv_part"] = ""
    end
    add_preterite_suffixes(forms, prefix .. "moh")
 
    return forms, title, categories
end

conjugations["irreg-povedať"] = function()
    -- irregular, only for perfective verbs derived from -vedať
    local forms = {}
    local categories = {"Slovak irregular verbs"}
    local title = "Conjugation of ''" .. PAGENAME .. "'' (irregular)"
 
    local prefix = remove_suffix(remove_reflexive_particle_and_suffix(PAGENAME, ""), "vedať")
 
    forms["infinitive"] = PAGENAME

    add_present_suffixes(forms, prefix .. "vie", prefix .. "ved", "ia")
    add_imperative_suffixes(forms, prefix .. "vedz")
    set_participles_etc(forms, prefix .. "veda", prefix .. "veda", "n")
    add_preterite_suffixes(forms, prefix .. "veda")
 
    return forms, title, categories
end

--[=[
    Partial conjugation functions
]=]--

function get_last_char(str)
    local last = mw.ustring.sub(str, -1, -1)
    return last
end

function remove_last_char(str)
    local stem = mw.ustring.sub(str, 1, -2)
    return stem
end

function remove_diacritics(str)

    local new_string = str
    new_string = mw.ustring.gsub(new_string, "č", "cj")
    new_string = mw.ustring.gsub(new_string, "ď", "dj")
    new_string = mw.ustring.gsub(new_string, "dž", "dzj")
    new_string = mw.ustring.gsub(new_string, "ľ", "lj")
    new_string = mw.ustring.gsub(new_string, "ň", "nj")
    new_string = mw.ustring.gsub(new_string, "š", "sj")
    new_string = mw.ustring.gsub(new_string, "ť", "tj")
    new_string = mw.ustring.gsub(new_string, "ž", "zj")

    return new_string
end

function soften_last_consonant(str)

    local consonants = {
        c = "č",
        d = "ď",
        l = "ľ",
        n = "ň",
        s = "š",
        t = "ť",
        z = "ž"
    }
    local last = get_last_char(str)
    local new_string = str
    if consonants[last] then
    	new_string = remove_last_char(str) .. consonants[last]
    end

    return new_string
end

function soften_last_given_consonant(str, consonants)

    local new_string = str

    if mw.ustring.find(str, "[" .. consonants .. "]$") then
        new_string = soften_last_consonant(str)
    end

    return new_string
end

function shorten_last_vowel(str)

    local last = get_last_char(str)
    last = mw.ustring.gsub(last, "á", "a")
    last = mw.ustring.gsub(last, "é", "e")
    last = mw.ustring.gsub(last, "í", "i")
    last = mw.ustring.gsub(last, "ó", "o")
    last = mw.ustring.gsub(last, "ú", "u")
    last = mw.ustring.gsub(last, "ý", "y")
    local new_string = remove_last_char(str) .. last

    return new_string
end

function ends_with_2_consonants(str)
    local cond = false

    if mw.ustring.find(str, "[bcčdďfghjklľmnňpqrsštťvwxzž][bcčdďfghjklľmnňpqrsštťvwxzž]$") and not mw.ustring.find(str, "ch$") and not mw.ustring.find(str, "d[zž]$") then
        cond = true
    end

    return cond
end

function ends_with_sylabic_cons_cluster(str)
    local cond = false

    if mw.ustring.find(str, "[bcčdďfghjkľmnňpqsštťvwxzž][rl][bcčdďfghjkľmnňpqysštťvwxzž]$") then
        cond = true
    end

    return cond
end

function remove_suffix(form, suffix)
    local base = form

    if mw.ustring.find(base, suffix .. "$") then
        local length = mw.ustring.len(suffix)
        base = mw.ustring.sub(base, 1, -length-1)
    end

    return base
end

function last_vowel(stem)
    local vowel = nil
    local letter = nil;
    --TODO: syllabic r?
    if (mw.ustring.find(stem, "[áéíóúýĺŕôaeiouyä]")) then
        for i=1,mw.ustring.len(stem) do
            letter = mw.ustring.sub(stem, -i, -i)
            if (mw.ustring.find(letter, "[áéíóúýĺŕôaeiouyä]")) then
                if (mw.ustring.find(letter, "[aeu]") and mw.ustring.sub(stem, -i-1, -i-1) == "i") then
                    vowel = "i" .. letter
                else
                    vowel = letter
                end
                break
            end
        end
    end

    return vowel
end

function last_syllable_long(stem)
    local is_long = false
    local last_vowel = last_vowel(stem)
    if last_vowel then
	    if (mw.ustring.find(last_vowel, "[áéíóúýĺŕô]") or mw.ustring.find(last_vowel, "i[aeu]")) then
	        is_long = true
	    end
	end

    return is_long
end

function get_reflexive_particle(inf)
	
	local particle = ""
	if mw.ustring.find(inf, " s[ai]$") then
		particle = mw.ustring.sub(inf, -2, -1)
	end
	return particle
end

function remove_reflexive_particle_and_suffix(inf, suffix)

    local stem = null
    if mw.ustring.find(inf, " s[ai]$") then
    	stem = remove_suffix(inf, suffix .. " " .. get_reflexive_particle(inf))
    else
    	stem = remove_suffix(inf, suffix)
    end

    return stem
end

function repl_dtnl_ei(str)

    local new_string = str
    new_string = mw.ustring.gsub(new_string, "ďe", "de")
    new_string = mw.ustring.gsub(new_string, "ťe", "te")
    new_string = mw.ustring.gsub(new_string, "ňe", "ne")
    new_string = mw.ustring.gsub(new_string, "ľe", "le")
    new_string = mw.ustring.gsub(new_string, "ďi", "di")
    new_string = mw.ustring.gsub(new_string, "ťi", "ti")
    new_string = mw.ustring.gsub(new_string, "ňi", "ni")
    new_string = mw.ustring.gsub(new_string, "ľi", "li")
    new_string = mw.ustring.gsub(new_string, "ďé", "dé")
    new_string = mw.ustring.gsub(new_string, "ťé", "té")
    new_string = mw.ustring.gsub(new_string, "ňé", "né")
    new_string = mw.ustring.gsub(new_string, "ľé", "lé")
    new_string = mw.ustring.gsub(new_string, "ďí", "dí")
    new_string = mw.ustring.gsub(new_string, "ťí", "tí")
    new_string = mw.ustring.gsub(new_string, "ňí", "ní")
    new_string = mw.ustring.gsub(new_string, "ľí", "lí")

    return new_string
end

function add_present_suffixes(forms, stem1, stem2, stem2suffix)

    local suffix2 = stem2suffix
    if last_syllable_long(stem2) and suffix2 == "ú" then
        suffix2 = "u"
    elseif mw.ustring.find(stem2, "j$") and suffix2 == "ia" then
        suffix2 = "a"
    end
    
    local stem1_dtnl = repl_dtnl_ei(stem1)
 
    forms["pres_futr_1sg"] = stem1_dtnl .. "m"
    forms["pres_futr_2sg"] = stem1_dtnl .. "š"
    forms["pres_futr_3sg"] = stem1_dtnl
    forms["pres_futr_1pl"] = stem1_dtnl .. "me"
    forms["pres_futr_2pl"] = stem1_dtnl .. "te"
    forms["pres_futr_3pl"] = repl_dtnl_ei(stem2 .. suffix2)
end

function add_imperative_suffixes(forms, stem)
    local st = stem
    local extra_i = ""
    if ends_with_2_consonants(st) and not ends_with_sylabic_cons_cluster(st) then
        extra_i = "i"
    end
    if mw.ustring.find(st, "[iy]j$") then
        st = remove_suffix(st, "j")
    end
    forms["impr_2sg"] = repl_dtnl_ei(st .. extra_i)
    forms["impr_1pl"] = repl_dtnl_ei(st .. extra_i .. "me")
    forms["impr_2pl"] = repl_dtnl_ei(st .. extra_i .. "te")
end

function add_preterite_suffixes(forms, stem)
    local extra_o = ""
    if mw.ustring.find(stem, "[bcčdďfghjklĺmnňpqrsštťvwxzž]$") then
        extra_o = "o"
    end
    
    local stem_dtnl = repl_dtnl_ei(stem)
    
    forms["past_m"] = stem_dtnl .. extra_o .. "l"
    forms["past_f"] = stem_dtnl .. "la"
    forms["past_n"] = stem_dtnl .. "lo"
    forms["past_pl"] = stem_dtnl .. "li"
end

function set_participles_etc(forms, stem1, stem2, pas_part_suffix)
    forms["pres_actv_part"] = forms["pres_futr_3pl"] .. "ci"
    if stem1 == nil then
        forms["past_actv_part"] = ""
    else
        forms["past_actv_part"] = repl_dtnl_ei(stem1 .. "vší")
    end
    if last_syllable_long(stem2 .. pas_part_suffix) then
    	forms["pres_pasv_part"] = repl_dtnl_ei(stem2 .. pas_part_suffix .. "y")
    else
    	forms["pres_pasv_part"] = repl_dtnl_ei(stem2 .. pas_part_suffix .. "ý")
    end
    forms["transgr"] = forms["pres_futr_3pl"] .. "c"
    forms["gerund"] = repl_dtnl_ei(stem2 .. pas_part_suffix .. "ie")
end

function create_composite(form, inf, tense, mood, person, gender, impers)
	
	impers = impers or false
	gender = gender or "p"

    local byt_pres = {" [[som#Slovak|som]]", " [[si#Slovak|si]]", "", " [[sme#Slovak|sme]]", " [[ste#Slovak|ste]]", ""}
    local bol_gend = {m="[[bol#Slovak|bol]]", f="[[bola#Slovak|bola]]", n="[[bolo#Slovak|bolo]]", p="[[boli#Slovak|boli]]"}
    local bude = {"[[budem#Slovak|budem]]", "[[budeš#Slovak|budeš]]", "[[bude#Slovak|bude]]", "[[budeme#Slovak|budeme]]", "[[budete#Slovak|budete]]", "[[budú#Slovak|budú]]"}
    local bude_nl = {"budem", "budeš", "bude", "budeme", "budete", "budú"}
    local byval = {m="býval", f="bývala", n="bývalo", p="bývali"}
    local pojde = {"pôjdem", "pôjdeš", "pôjde", "pôjdeme", "pôjdete", "pôjdu"}
    local by = " [[by#Slovak|by]]"
    
    local refl = ""
    if mw.ustring.find(inf, " s[ai]$") then refl = " " .. get_reflexive_particle(inf) end
    local refl_space = refl .. " "
    
    if person > 3 then gender = "p" end
    
    if inf == "byť" and mood == "cond" and (tense == "past" or tense == "past perfect") then
    	form = byval[gender]
    end
    
    local accel_form = ""
    if tense == "past" and mood == "ind" and person % 3 == 0 then
    	if person == 3 then
    		accel_form = gender .. "|3|s|past|ind"
    	elseif person == 6 then
    		accel_form = "3|p|past|ind"
    	end
    elseif gender == "p" then
    	accel_form = "p|l-ptcp"
    else
    	accel_form = gender .. "|s|l-ptcp"
    end
    
    if tense ~= "fut" then form = make_link(form, accel_form) end

    local result = nil
    if tense == "past" then
        if mood == "ind" then
            result = form .. byt_pres[person] .. refl
        elseif mood == "cond" then
            result = bol_gend[gender] .. by .. byt_pres[person] .. refl_space .. form
        end
    elseif tense == "past perfect" and mood == "ind" then
        result = bol_gend[gender] .. byt_pres[person] .. refl_space .. form
    elseif tense == "present" and mood == "cond" then
        result = form .. by .. byt_pres[person] .. refl
    elseif tense == "fut" then
    	if inf == "ísť" then
    		result = make_link(pojde[person], (((person - 1) % 3) + 1) .. "|" .. ((person <= 3) and "s" or "p") .. "|fut|ind")
    	elseif inf == "byť" then
    		result = make_link(bude_nl[person], (((person - 1) % 3) + 1) .. "|" .. ((person <= 3) and "s" or "p") .. "|fut|ind")
    	elseif impers and person ~= 3 then
    		result = "&mdash;"
    	else
        	result = bude[person] .. refl_space .. remove_suffix(inf, refl)
        end
    end

    return result
end
 
 
-- Add the reflexive particle to all verb forms
function make_reflexive(forms)
    for key, form in pairs(forms) do
        if form ~= "" and not mw.ustring.find(form, " s[ai]$") and not mw.ustring.find(key, "past_[mfnp]") and not mw.ustring.find(key, "pres_pasv_part") then
            forms[key] = form .. " " .. get_reflexive_particle(forms["infinitive"])
        end
    end
end

function make_link(link, accel_form)
    local new_link = link

    -- Check if the link ends with " sa" or " si"
    local ending = get_reflexive_particle(link)

    if #ending > 0 then
        -- Remove the ending from the link
        link = remove_suffix(link, " " .. ending)
    end

    -- If link is not empty, valid, and not "&mdash;", create the full link
    if link ~= "" and link and link ~= "&mdash;" then
        new_link = m_links.full_link({lang = lang, term = link, accel = {form = accel_form}})
    end
    
    if #ending > 0 then
        new_link = new_link .. " " .. ending
    end

    return new_link
end

function convert_to_accel(input)
    -- Define mappings for person, number, tense, mood, and other specific cases
    local mood_map = {
        pres = "ind",
        futr = "ind",
        impr = "imp"
    }
    
    local tense_map = {
        pres = "pres",
        futr = "fut",
        impr = "pres"  -- For imperative, tense is always present
    }

    -- Handle special cases
    local special_cases = {
        ["pres_actv_part"] = "pres|act|part",
        ["past_actv_part"] = "past|act|part",  -- Assuming 'past' is passive
        ["pres_pasv_part"] = "pasv|part",
        ["past_m"] = "m|s|l-ptcp",
        ["transgr"] = "transgressive",
        ["gerund"] = "vnoun"
    }

    -- Check if the input matches any special case
    if special_cases[input] then
        return special_cases[input]
    end

    -- Otherwise, proceed with regular tense/mood parsing
    local tense_mood, person_number = input:match("([a-z]+)_([0-9]+[sp]+)")

    -- Extract person and number
    local person = person_number:match("([1-3])")
    local number = person_number:match("([sp])")

    -- Convert tense/mood
    local tense = tense_map[tense_mood]
    local mood = mood_map[tense_mood]

    -- Format the result as "person|number|(tense)|mood"
    if tense_mood == "impr" then
    	return string.format("%s|%s|%s", person, number, mood)
    else
    	return string.format("%s|%s|%s|%s", person, number, tense, mood)
    end
end

function check_add_alt(forms, id, impers)
	local accel_form = convert_to_accel(id)
    local result = make_link(forms[id], accel_form)
    if id == "past_m" and impers then
    	result = make_link(forms["past_n"])
    	if forms["past_n2"] then result = result .. ",<br />" .. make_link(forms["past_n2"], accel_form) end
    elseif id == "past_m" then
    	result = make_link(forms[id], accel_form) .. ", "
    	.. make_link(forms["past_f"], "f|s|l-ptcp") .. ", "
    	.. make_link(forms["past_n"], "n|s|l-ptcp") .. ", "
    	.. make_link(forms["past_pl"], "p|l-ptcp")
    	if forms[id .. "2"] and forms["past_f2"] and forms["past_n2"] and forms["past_pl2"] then
    		result = result .. "<br />" .. make_link(forms[id .. "2"], accel_form) .. ", "
    		.. make_link(forms["past_f2"], "f|s|l-ptcp") .. ", "
    		.. make_link(forms["past_n2"], "n|s|l-ptcp") .. ", "
    		.. make_link(forms["past_pl2"], "p|l-ptcp")
    	end
    else
    	if forms[id .. "2"] then result = result .. ",<br />" .. make_link(forms[id .. "2"], accel_form) end
    end

    return result
end

function check_add_alt_comp(forms, tense, mood, gender, person)
    local result = ""
    result = create_composite(forms["past_" .. gender], forms["infinitive"], tense, mood, person, gender)
    if forms["past_" .. gender .. "2"] then
        result = result .. ",<br />" .. create_composite(forms["past_" .. gender .. "2"], forms["infinitive"], tense, mood, person, gender)
    end

    return result
end

function make_table_header(title)
    local header = [=[<div class="NavFrame">
    <div class="NavHead">]=] .. title .. [=[</div>
    <div class="NavContent">
    <table style="text-align:center; width:100%" class="inflection-table">]=]

    return header
end

function make_simple_row(label, form)
    local row = [=[<tr style="height:2em;">
        <th colspan="3" style="background:#d0d0d0;">]=] .. label .. [=[</th>
        <td colspan="5"><span lang=\"sk\">''']=] .. form .. [=['''</span></td>
    </tr>]=]

    return row
end

function make_mood_header(mood, colour)
    local header = [=[<tr>
    <th colspan="2" rowspan="2" style="background:]=] .. colour .. [=[">]=] .. mood .. [=[</th>
    <th colspan="3" style="background:]=] .. colour .. [=[">''singular''</th>
    <th colspan="3" style="background:]=] .. colour .. [=[">''plural''</th>
    </tr>
    <tr>
    <th style="background:]=] .. colour .. [=[">[[first person|first]]</th>
    <th style="background:]=] .. colour .. [=[">[[second person|second]]</th>
    <th style="background:]=] .. colour .. [=[">[[third person|third]]</th>
    <th style="background:]=] .. colour .. [=[">[[first person|first]]</th>
    <th style="background:]=] .. colour .. [=[">[[second person|second]]</th>
    <th style="background:]=] .. colour .. [=[">[[third person|third]]</th>
    </tr>]=]

    return header
end

function make_indecl_header(colour)
    local header = [=[<tr>
    <th colspan="2" rowspan="3" style="background:]=] .. colour .. [=[">non-finite forms</th>
    <th colspan="4" style="background:]=] .. colour .. [=[">participles</th>
    <th rowspan="2" style="background:]=] .. colour .. [=[">transgressive</th>
    <th rowspan="2" style="background:]=] .. colour .. [=[">verbal noun</th>
    </tr>
    <tr>
    <th style="background:]=] .. colour .. [=[">present active</th>
    <th style="background:]=] .. colour .. [=[">past active</th>
    <th style="background:]=] .. colour .. [=[">passive</th>
    <th style="background:]=] .. colour .. [=[">l-participle</th>
    </tr>]=]

    return header
end

function make_full_row(tense, colour, form1, form2, form3, form4, form5, form6)
	local first_col = ""
	if tense ~= "non-finite" then
    	first_col = [=[<th colspan="2" style="background:]=] .. colour .. [=[; width:7em">]=] .. tense .. [=[</th>]=]
    end
    local row = [=[<tr>]=]
    .. first_col ..
    [=[<td><span lang=\"sk\">]=] .. form1 .. [=[</span></td>
    <td><span lang=\"sk\">]=] .. form2 .. [=[</span></td>
    <td><span lang=\"sk\">]=] .. form3 .. [=[</span></td>
    <td><span lang=\"sk\">]=] .. form4 .. [=[</span></td>
    <td><span lang=\"sk\">]=] .. form5 .. [=[</span></td>
    <td><span lang=\"sk\">]=] .. form6 .. [=[</span></td>
    </tr>]=]
    row = row .. add_row_separator()

    return row
end

function add_row_separator()
	if #IMPERS > 0 then
		return ""
	else
		return "<tr style=\"height: 0px;\"><td colspan=\"8\" style=\"height: 0px; padding: 0;\"></td></tr>"
	end
end

function make_full_row_comp(tense, colour, forms, mood, impers)
	local row = ""
	
	if impers then
		row = make_full_row(tense, colour, "&mdash;", "&mdash;", check_add_alt_comp(forms, tense, mood, "n", 3), "&mdash;", "&mdash;", "&mdash;")
	else
		row = [=[<tr style="line-height: 1.2;">
	        <th rowspan="3" style="background:]=] .. colour .. [=[; width:7em">]=] .. tense .. [=[</th>
	        <th style="background:]=] .. colour .. [=[; width:7em; padding-bottom: 0;">masculine</th>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "m", 1) .. [=[</span></td>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "m", 2) .. [=[</span></td>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "m", 3) .. [=[</span></td>
	        <td rowspan="3"><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "pl", 4) .. [=[</span></td>
	        <td rowspan="3"><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "pl", 5) .. [=[</span></td>
	        <td rowspan="3"><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "pl", 6) .. [=[</span></td>
	    </tr>
	    <tr style="line-height: 1.2;">
	        <th style="background:]=] .. colour .. [=[; width:7em; padding-top: 0; padding-bottom: 0;"">feminine</th>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "f", 1) .. [=[</span></td>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "f", 2) .. [=[</span></td>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "f", 3) .. [=[</span></td>
	    </tr>
	    <tr style="line-height: 1.2;">
	        <th style="background:]=] .. colour .. [=[; width:7em; padding-top: 0;">neuter</th>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "n", 1) .. [=[</span></td>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "n", 2) .. [=[</span></td>
	        <td><span lang=\"sk\">]=] .. check_add_alt_comp(forms, tense, mood, "n", 3) .. [=[</span></td>
	    </tr>]=]
	    row = row .. add_row_separator()
	end

    return row
end

function make_table_footer()
    local header = [=[</table></div></div>]=]

    return header
end
 
-- Make the table
function make_table(forms, title, cats, params)
 
    if cats["impers"] then
        forms["pres_futr_1sg"] = ""
        forms["pres_futr_2sg"] = ""
        forms["pres_futr_1pl"] = ""
        forms["pres_futr_2pl"] = ""
        forms["pres_futr_3pl"] = ""
        forms["past_m"] = ""
        forms["past_f"] = ""
        forms["past_pl"] = ""
        forms["pres_actv_part"] = ""
        forms["past_actv_part"] = ""
        forms["transgr"] = ""
        forms["impr_2sg"] = ""
        forms["impr_1pl"] = ""
        forms["impr_2pl"] = ""
        --alternatives
        forms["pres_futr_1sg2"] = nil
        forms["pres_futr_2sg2"] = nil
        forms["pres_futr_1pl2"] = nil
        forms["pres_futr_2pl2"] = nil
        forms["pres_futr_3pl2"] = nil
        forms["past_m2"] = nil
        forms["past_m3"] = nil
        forms["past_f2"] = nil
        forms["past_pl2"] = nil
        forms["pres_actv_part2"] = nil
        forms["past_actv_part2"] = nil
        forms["transgr2"] = nil
        forms["impr_2sg"] = nil
        forms["impr_1pl"] = nil
        forms["impr_2pl"] = nil
    end
 
    -- Perfective verbs have no present forms.
    if cats["perf"] then
        forms["pres_actv_part"] = ""
        forms["pres_1sg"] = ""
        forms["pres_2sg"] = ""
        forms["pres_3sg"] = ""
        forms["pres_1pl"] = ""
        forms["pres_2pl"] = ""
        forms["pres_3pl"] = ""
        --alternatives
        forms["pres_actv_part2"] = nil
        forms["pres_1sg2"] = nil
        forms["pres_2sg2"] = nil
        forms["pres_3sg2"] = nil
        forms["pres_1pl2"] = nil
        forms["pres_2pl2"] = nil
        forms["pres_3pl2"] = nil
 
        forms["futr_1sg"] = forms["pres_futr_1sg"]
        forms["futr_2sg"] = forms["pres_futr_2sg"]
        forms["futr_3sg"] = forms["pres_futr_3sg"]
        forms["futr_1pl"] = forms["pres_futr_1pl"]
        forms["futr_2pl"] = forms["pres_futr_2pl"]
        forms["futr_3pl"] = forms["pres_futr_3pl"]
        -- alternatives
        forms["futr_1sg2"] = forms["pres_futr_1sg2"]
        forms["futr_2sg2"] = forms["pres_futr_2sg2"]
        forms["futr_3sg2"] = forms["pres_futr_3sg2"]
        forms["futr_1pl2"] = forms["pres_futr_1pl2"]
        forms["futr_2pl2"] = forms["pres_futr_2pl2"]
        forms["futr_3pl2"] = forms["pres_futr_3pl2"]        
    else
    	forms["past_actv_part"] = ""
        forms["pres_1sg"] = forms["pres_futr_1sg"]
        forms["pres_2sg"] = forms["pres_futr_2sg"]
        forms["pres_3sg"] = forms["pres_futr_3sg"]
        forms["pres_1pl"] = forms["pres_futr_1pl"]
        forms["pres_2pl"] = forms["pres_futr_2pl"]
        forms["pres_3pl"] = forms["pres_futr_3pl"]
        forms["pres_2sg"] = forms["pres_futr_2sg"]
        -- alternatives
        forms["pres_1sg2"] = forms["pres_futr_1sg2"]
        forms["pres_2sg2"] = forms["pres_futr_2sg2"]
        forms["pres_3sg2"] = forms["pres_futr_3sg2"]
        forms["pres_1pl2"] = forms["pres_futr_1pl2"]
        forms["pres_2pl2"] = forms["pres_futr_2pl2"]
        forms["pres_3pl2"] = forms["pres_futr_3pl2"]  
    end

    if cats["impers"] then
        forms["futr_1sg"] = ""
        forms["futr_2sg"] = ""
        forms["futr_1pl"] = ""
        forms["futr_2pl"] = ""
        forms["futr_3pl"] = ""
        --alternatives
        forms["futr_1sg2"] = nil
        forms["futr_2sg2"] = nil
        forms["futr_1pl2"] = nil
        forms["futr_2pl2"] = nil
        forms["futr_3pl2"] = nil
    end
 
    local inf = forms["infinitive"]
 
    for key, form in pairs(forms) do
        -- check for empty strings and nil's
        if form == "" or not form then
            forms[key] = "&mdash;"
        end
    end

    local final = make_table_header(title)
    final = final .. make_simple_row("infinitive", inf)

    final = final .. make_mood_header("indicative", "#A0ADE3")

    if not cats["perf"] then
        final = final .. make_full_row(
            "present",
            "#C0CFE4",
            check_add_alt(forms, "pres_1sg", cats["impers"]),
            check_add_alt(forms, "pres_2sg", cats["impers"]),
            check_add_alt(forms, "pres_3sg", cats["impers"]),
            check_add_alt(forms, "pres_1pl", cats["impers"]),
            check_add_alt(forms, "pres_2pl", cats["impers"]),
            check_add_alt(forms, "pres_3pl", cats["impers"])
        )
    end
    final = final .. make_full_row_comp("past", "#C0CFE4", forms, "ind", cats["impers"])
    final = final .. make_full_row_comp("past perfect", "#C0CFE4", forms, "ind", cats["impers"])
    if cats["perf"] then
        final = final .. make_full_row(
            "future",
            "#C0CFE4",
            check_add_alt(forms, "futr_1sg", cats["impers"]),
            check_add_alt(forms, "futr_2sg", cats["impers"]),
            check_add_alt(forms, "futr_3sg", cats["impers"]),
            check_add_alt(forms, "futr_1pl", cats["impers"]),
            check_add_alt(forms, "futr_2pl", cats["impers"]),
            check_add_alt(forms, "futr_3pl", cats["impers"])
        )
    else
        final = final .. make_full_row(
            "future",
            "#C0CFE4",
            create_composite(nil, inf, "fut", nil, 1, nil, cats["impers"]),
            create_composite(nil, inf, "fut", nil, 2, nil, cats["impers"]),
            create_composite(nil, inf, "fut", nil, 3, nil, cats["impers"]),
            create_composite(nil, inf, "fut", nil, 4, nil, cats["impers"]),
            create_composite(nil, inf, "fut", nil, 5, nil, cats["impers"]),
            create_composite(nil, inf, "fut", nil, 6, nil, cats["impers"])
        )
    end


    final = final .. make_mood_header("conditional", "#A7D8B8")
    final = final .. make_full_row_comp("present", "#B2E8A6", forms, "cond", cats["impers"])
    final = final .. make_full_row_comp("past", "#B2E8A6", forms, "cond", cats["impers"])

	if (forms["impr_2sg"] and forms["impr_1pl"] and forms["impr_2pl"] and not params["no_impr"] and not cats["impers"]) then
	    final = final .. make_mood_header("imperative", "#F4A7A7")
	    final = final .. make_full_row(
	        "present",
	        "#F7B2B7",
	        "—",
	        check_add_alt(forms, "impr_2sg", cats["impers"]),
	        "—",
	        check_add_alt(forms, "impr_1pl", cats["impers"]),
	        check_add_alt(forms, "impr_2pl", cats["impers"]),
	        "—"
	    )
	end
	
	local pasv_part_final, gerund_final = "&mdash;", "&mdash;"
	if not params["no_pasv_part"] and (not cats["refl"] or params["pasv_part"]) and (not cats["impers"] or cats["perf"] or params["pasv_part"]) then
    	pasv_part_final = check_add_alt(forms, "pres_pasv_part", cats["impers"])
	end

    if not params["no_gerund"] then
    	gerund_final = check_add_alt(forms, "gerund", cats["impers"])
    end
	
	final = final .. make_indecl_header("#F3F781")
	final = final .. make_full_row(
        "non-finite",
        "#F2F5A9",
        check_add_alt(forms, "pres_actv_part", cats["impers"]),
        check_add_alt(forms, "past_actv_part", cats["impers"]),
        pasv_part_final,
        check_add_alt(forms, "past_m", cats["impers"]),
        check_add_alt(forms, "transgr", cats["impers"]),
        gerund_final
    )

    final = final .. make_table_footer()
 
    return final
end
 
return export