Module:sk-verb

--[=[   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 = {}

-- 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 }   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 if perf then table.insert(categories, "Slovak perfective verbs") else table.insert(categories, "Slovak imperfective verbs") end -- 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 .. ""       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 .. " (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 .. " (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 .. " (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 .. " (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 .. " (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 .. " (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 .. " (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 .. " (class IV, pattern žať'')" local stem = remove_reflexive_particle_and_suffix(PAGENAME, "ť") stem = remove_reflexive_particle_and_suffix(stem, get_last_char(stem))

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 .. "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, "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 .. " (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 .. " (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 .. " (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 .. " (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 .. " (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 .. " (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" 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 .. " (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, gender, person, impers)

local byt_pres = {" som", " si", "", " sme", " ste", ""} local bol_gend = {m="bol", f="bola", n="bolo", p="boli"} local bude = {"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 refl = "" if mw.ustring.find(inf, " s[ai]$") then refl = " " .. get_reflexive_particle(inf) end local refl_space = refl .. " "   if inf == "byť" then if mood == "cond" and tense == "past" or tense == "ptpf" then form = byval[gender] end if tense == "fut" then refl_space = "" inf = "" end 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 == "ptpf" and mood == "ind" then result = bol_gend[gender] .. byt_pres[person] .. refl_space .. form elseif tense == "pres" and mood == "cond" then result = form .. " by" .. byt_pres[person] .. refl elseif tense == "fut" then if inf == "ísť" then result = pojde[person] 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) local new_link = link if link ~= "" and link and link ~= "&mdash;" then new_link = "" .. link .. "" end

return new_link end

function check_add_alt(forms, id, impers) local result = make_link(forms[id]) if id ~= "past_m" then if forms[id .. "2"] then result = result .. " " .. make_link(forms[id .. "2"]) end elseif impers then result = make_link(forms["past_n"]) if forms["past_n2"] then result = result .. " " .. make_link(forms["past_n2"]) end else result = result .. ", " .. make_link(forms["past_f"]) .. ", " .. make_link(forms["past_n"]) .. ", " .. make_link(forms["past_pl"]) if forms["past_m2"] and forms["past_f2"] and forms["past_n2"] and forms["past_pl2"] then result = result .. " " .. make_link(forms["past_m2"]) .. ", " .. make_link(forms["past_f2"]) .. ", " .. make_link(forms["past_n2"]) .. ", " .. make_link(forms["past_pl2"]) end end

return result end

function check_add_alt_comp(forms, id, tense, mood, person, impers) local result = "" if not impers then if person <= 3 then result = create_composite(forms[id .. "_m"], forms["infinitive"], tense, mood, "m", person, impers) result = result .. " " .. create_composite(forms[id .. "_f"], forms["infinitive"], tense, mood, "f", person, impers) result = result .. " " .. create_composite(forms[id .. "_n"], forms["infinitive"], tense, mood, "n", person, impers) if forms[id .. "_m2"] and forms[id .. "_f2"] and forms[id .. "_n2"] then result = result .. " " .. create_composite(forms[id .. "_m2"], forms["infinitive"], tense, mood, "m", person, impers) result = result .. " " .. create_composite(forms[id .. "_f2"], forms["infinitive"], tense, mood, "f", person, impers) result = result .. " " .. create_composite(forms[id .. "_n2"], forms["infinitive"], tense, mood, "n", person, impers) end else result = create_composite(forms[id .. "_pl"], forms["infinitive"], tense, mood, "p", person, impers) if forms[id .. "_pl2"] then result = result .. " " .. create_composite(forms[id .. "_pl2"], forms["infinitive"], tense, mood, "p", person, impers) end end else if person == 3 then result = create_composite(forms[id .. "_n"], forms["infinitive"], tense, mood, "n", person, impers) if forms[id .. "_n2"] then result = result .. " " .. create_composite(forms[id .. "_n2"], forms["infinitive"], tense, mood, "n", person, impers) end else result = "&mdash;" end end

return result end

function make_table_header(title) local header = [=[ ]=] .. title .. [=[      ]=]

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 gender_note_long = " (m./f./n./pl.) " local gender_note = " (m./f./n.) " if cats["impers"] then gender_note_long = "" gender_note = "" end

local final = make_table_header(title)

final = final .. make_simple_row("infinitive", inf) final = final .. make_simple_row("present active participle", check_add_alt(forms, "pres_actv_part", cats["impers"])) final = final .. make_simple_row("past active participle", check_add_alt(forms, "past_actv_part", cats["impers"])) if params["no_pasv_part"] or (cats["refl"] and not params["pasv_part"]) or (cats["impers"] and not cats["perf"] and not params["pasv_part"]) then final = final .. make_simple_row("passive participle", "&mdash;") else final = final .. make_simple_row("passive participle", check_add_alt(forms, "pres_pasv_part", cats["impers"])) end final = final .. make_simple_row("l-participle" .. gender_note_long, check_add_alt(forms, "past_m", cats["impers"])) final = final .. make_simple_row("transgressive", check_add_alt(forms, "transgr", cats["impers"])) if params["no_gerund"] then final = final .. make_simple_row("gerund", "&mdash;") else final = final .. make_simple_row("gerund", check_add_alt(forms, "gerund", cats["impers"])) end

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" .. gender_note, "#C0CFE4", forms, "past", "past", "ind", cats["impers"]) final = final .. make_full_row_comp("past perfect" .. gender_note, "#C0CFE4", forms, "past", "ptpf", "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, nil, 1, cats["impers"]),            create_composite(nil, inf, "fut", nil, nil, 2, cats["impers"]),            create_composite(nil, inf, "fut", nil, nil, 3, cats["impers"]),            create_composite(nil, inf, "fut", nil, nil, 4, cats["impers"]),            create_composite(nil, inf, "fut", nil, nil, 5, cats["impers"]),            create_composite(nil, inf, "fut", nil, nil, 6, cats["impers"])        ) end

final = final .. make_mood_header("conditional", "#01DF74") final = final .. make_full_row_comp("present" .. gender_note, "#00FF80", forms, "past", "pres", "cond", cats["impers"]) final = final .. make_full_row_comp("past" .. gender_note, "#00FF80", forms, "past", "past", "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", "#F3F781") final = final .. make_full_row(	       "present",	        "#F2F5A9",	        "—",	        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

final = final .. make_table_footer return final end return export