--[=[
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 then
PAGENAME = args
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 or (NAMESPACE == "Template" and "impf") or error("Verb type has not been specified. Please pass parameter 1")
local conj_type = args or error("Conjugation type has not been specified. Please pass parameter 2")
--reflexive
local refl = false
if mw.ustring.find(verb_type, "s") then
refl = true
PAGENAME = PAGENAME .. " " .. mw.ustring.match(verb_type, "s")
elseif mw.ustring.find(PAGENAME, " s$") 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 then
forms, title, categories = conjugations(args)
else
error("Unknown conjugation type '" .. conj_type .. "'")
end
--alternative forms
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
forms = args
if args then forms = args end
if args then forms = args end
--parameters passed by the user
local no_impr = args
local no_pasv_part = args
local no_gerund = args
local pasv_part = args
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 = 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, "$") 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 = 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 = 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 = 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 = 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 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
local pres_stem1 = pres_stem1_0 .. "ie"
local inf_stem = remove_last_char(stem) .. alternations
if mw.ustring.find(stem, "rás$") then inf_stem = remove_last_char(stem) .. "st" end
forms = 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 = 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, "$") 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 = 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 = 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 = 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 = 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 = 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 = 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 then
stem2 = remove_suffix(stem, stem_last) .. alternations
end
local pres_stem1 = soften_last_given_consonant(stem2, "nl") .. "e"
local pres_stem2 = stem2
local inf_stem = stem .. "a"
forms = 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 = 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 = 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 = 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 = 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 = 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$") then
if args then
stem2 = remove_last_char(args)
else
stem2 = mw.ustring.sub(stem, 1, -3) .. "e"
end
else
-- for doublets kovať, žuvať and snovať
if args then
stem2 = args
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 = 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 = 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 = 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 = 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, "$") 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 = 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 = 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, "$") then
stem = soften_last_consonant(stem)
end
local pres_stem1 = stem .. "í"
local pres_stem2 = stem
local inf_stem = stem .. "e"
forms = 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 = 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 = 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 = 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 = PAGENAME
forms = prefix .. "som"
forms = prefix .. "si"
forms = prefix .. "je"
forms = prefix .. "sme"
forms = prefix .. "ste"
forms = prefix .. "sú"
add_imperative_suffixes(forms, prefix .. "buď")
set_participles_etc(forms, prefix .. "by", prefix .. "by", "t")
forms = ""
add_preterite_suffixes(forms, prefix .. "bo")
return forms, title, categories
end
conjugations = 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 = 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 = ""
add_preterite_suffixes(forms, prefix .. "jed")
return forms, title, categories
end
conjugations = 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 = 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 = 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 = 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 = prefix .. "chcejúc"
add_preterite_suffixes(forms, prefix .. "chce")
return forms, title, categories
end
conjugations = 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 = 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 = preterite_stem .. "iel"
return forms, title, categories
end
conjugations = 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 = 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 = 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 = 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 = 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 = 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 = ""
forms = ""
end
add_preterite_suffixes(forms, prefix .. "moh")
return forms, title, categories
end
conjugations = 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 = 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 then
new_string = remove_last_char(str) .. consonants
end
return new_string
end
function soften_last_given_consonant(str, consonants)
local new_string = str
if mw.ustring.find(str, "$") 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, "$") and not mw.ustring.find(str, "ch$") and not mw.ustring.find(str, "d$") then
cond = true
end
return cond
end
function ends_with_sylabic_cons_cluster(str)
local cond = false
if mw.ustring.find(str, "$") 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, "")) then
for i=1,mw.ustring.len(stem) do
letter = mw.ustring.sub(stem, -i, -i)
if (mw.ustring.find(letter, "")) then
if (mw.ustring.find(letter, "") 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")) then
is_long = true
end
end
return is_long
end
function get_reflexive_particle(inf)
local particle = ""
if mw.ustring.find(inf, " s$") 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$") 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 = stem1_dtnl .. "m"
forms = stem1_dtnl .. "š"
forms = stem1_dtnl
forms = stem1_dtnl .. "me"
forms = stem1_dtnl .. "te"
forms = 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, "j$") then
st = remove_suffix(st, "j")
end
forms = repl_dtnl_ei(st .. extra_i)
forms = repl_dtnl_ei(st .. extra_i .. "me")
forms = repl_dtnl_ei(st .. extra_i .. "te")
end
function add_preterite_suffixes(forms, stem)
local extra_o = ""
if mw.ustring.find(stem, "$") then
extra_o = "o"
end
local stem_dtnl = repl_dtnl_ei(stem)
forms = stem_dtnl .. extra_o .. "l"
forms = stem_dtnl .. "la"
forms = stem_dtnl .. "lo"
forms = stem_dtnl .. "li"
end
function set_participles_etc(forms, stem1, stem2, pas_part_suffix)
forms = forms .. "ci"
if stem1 == nil then
forms = ""
else
forms = repl_dtnl_ei(stem1 .. "vší")
end
if last_syllable_long(stem2 .. pas_part_suffix) then
forms = repl_dtnl_ei(stem2 .. pas_part_suffix .. "y")
else
forms = repl_dtnl_ei(stem2 .. pas_part_suffix .. "ý")
end
forms = forms .. "c"
forms = 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$") 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 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 .. refl
elseif mood == "cond" then
result = bol_gend .. " by" .. byt_pres .. refl_space .. form
end
elseif tense == "ptpf" and mood == "ind" then
result = bol_gend .. byt_pres .. refl_space .. form
elseif tense == "pres" and mood == "cond" then
result = form .. " by" .. byt_pres .. refl
elseif tense == "fut" then
if inf == "ísť" then
result = pojde
elseif impers and person ~= 3 then
result = "—"
else
result = bude .. 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$") and not mw.ustring.find(key, "past_") and not mw.ustring.find(key, "pres_pasv_part") then
forms = form .. " " .. get_reflexive_particle(forms)
end
end
end
function make_link(link)
local new_link = link
if link ~= "" and link and link ~= "—" then
new_link = "]"
end
return new_link
end
function check_add_alt(forms, id, impers)
local result = make_link(forms)
if id ~= "past_m" then
if forms then result = result .. "<br />" .. make_link(forms) end
elseif impers then
result = make_link(forms)
if forms then result = result .. "<br />" .. make_link(forms) end
else
result = result .. ", " .. make_link(forms) .. ", " .. make_link(forms) .. ", " .. make_link(forms)
if forms and forms and forms and forms then
result = result .. "<br />" .. make_link(forms) .. ", " .. make_link(forms) .. ", " .. make_link(forms) .. ", " .. make_link(forms)
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, forms, tense, mood, "m", person, impers)
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "f", person, impers)
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "n", person, impers)
if forms and forms and forms then
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "m", person, impers)
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "f", person, impers)
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "n", person, impers)
end
else
result = create_composite(forms, forms, tense, mood, "p", person, impers)
if forms then
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "p", person, impers)
end
end
else
if person == 3 then
result = create_composite(forms, forms, tense, mood, "n", person, impers)
if forms then
result = result .. "<br />" .. create_composite(forms, forms, tense, mood, "n", person, impers)
end
else
result = "—"
end
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>
<th colspan="2" 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 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 .. ]</th>
<th style="background:]=] .. colour .. ]</th>
<th style="background:]=] .. colour .. ]</th>
<th style="background:]=] .. colour .. ]</th>
<th style="background:]=] .. colour .. ]</th>
<th style="background:]=] .. colour .. ]</th>
</tr>]=]
return header
end
function make_full_row(tense, colour, form1, form2, form3, form4, form5, form6)
local row = [=[<tr>
<th style="background:]=] .. colour .. =] .. tense .. [=[</th>
<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>]=]
return row
end
function make_full_row_comp(tense, colour, forms, id, tense2, mood, impers)
local row = make_full_row(
tense,
colour,
check_add_alt_comp(forms, id, tense2, mood, 1, impers),
check_add_alt_comp(forms, id, tense2, mood, 2, impers),
check_add_alt_comp(forms, id, tense2, mood, 3, impers),
check_add_alt_comp(forms, id, tense2, mood, 4, impers),
check_add_alt_comp(forms, id, tense2, mood, 5, impers),
check_add_alt_comp(forms, id, tense2, mood, 6, impers)
)
return row
end
function make_table_footer()
local header = =]
return header
end
-- Make the table
function make_table(forms, title, cats, params)
if cats then
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
--alternatives
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
end
-- Perfective verbs have no present forms.
if cats then
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
--alternatives
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
-- alternatives
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
else
forms = ""
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
-- alternatives
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
forms = forms
end
if cats then
forms = ""
forms = ""
forms = ""
forms = ""
forms = ""
--alternatives
forms = nil
forms = nil
forms = nil
forms = nil
forms = nil
end
local inf = forms
for key, form in pairs(forms) do
-- check for empty strings and nil's
if form == "" or not form then
forms = "—"
end
end
local gender_note_long = " <small>(m./f./n./pl.)</small>"
local gender_note = " <small>(m./f./n.)</small>"
if cats 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))
final = final .. make_simple_row("past active participle", check_add_alt(forms, "past_actv_part", cats))
if params or (cats and not params) or (cats and not cats and not params) then
final = final .. make_simple_row("passive participle", "—")
else
final = final .. make_simple_row("passive participle", check_add_alt(forms, "pres_pasv_part", cats))
end
final = final .. make_simple_row("l-participle" .. gender_note_long, check_add_alt(forms, "past_m", cats))
final = final .. make_simple_row("transgressive", check_add_alt(forms, "transgr", cats))
if params then
final = final .. make_simple_row("gerund", "—")
else
final = final .. make_simple_row("gerund", check_add_alt(forms, "gerund", cats))
end
final = final .. make_mood_header("indicative", "#A0ADE3")
if not cats then
final = final .. make_full_row(
"present",
"#C0CFE4",
check_add_alt(forms, "pres_1sg", cats),
check_add_alt(forms, "pres_2sg", cats),
check_add_alt(forms, "pres_3sg", cats),
check_add_alt(forms, "pres_1pl", cats),
check_add_alt(forms, "pres_2pl", cats),
check_add_alt(forms, "pres_3pl", cats)
)
end
final = final .. make_full_row_comp("past" .. gender_note, "#C0CFE4", forms, "past", "past", "ind", cats)
final = final .. make_full_row_comp("past perfect" .. gender_note, "#C0CFE4", forms, "past", "ptpf", "ind", cats)
if cats then
final = final .. make_full_row(
"future",
"#C0CFE4",
check_add_alt(forms, "futr_1sg", cats),
check_add_alt(forms, "futr_2sg", cats),
check_add_alt(forms, "futr_3sg", cats),
check_add_alt(forms, "futr_1pl", cats),
check_add_alt(forms, "futr_2pl", cats),
check_add_alt(forms, "futr_3pl", cats)
)
else
final = final .. make_full_row(
"future",
"#C0CFE4",
create_composite(nil, inf, "fut", nil, nil, 1, cats),
create_composite(nil, inf, "fut", nil, nil, 2, cats),
create_composite(nil, inf, "fut", nil, nil, 3, cats),
create_composite(nil, inf, "fut", nil, nil, 4, cats),
create_composite(nil, inf, "fut", nil, nil, 5, cats),
create_composite(nil, inf, "fut", nil, nil, 6, cats)
)
end
final = final .. make_mood_header("conditional", "#01DF74")
final = final .. make_full_row_comp("present" .. gender_note, "#00FF80", forms, "past", "pres", "cond", cats)
final = final .. make_full_row_comp("past" .. gender_note, "#00FF80", forms, "past", "past", "cond", cats)
if (forms and forms and forms and not params and not cats) then
final = final .. make_mood_header("imperative", "#F3F781")
final = final .. make_full_row(
"present",
"#F2F5A9",
"—",
check_add_alt(forms, "impr_2sg", cats),
"—",
check_add_alt(forms, "impr_1pl", cats),
check_add_alt(forms, "impr_2pl", cats),
"—"
)
end
final = final .. make_table_footer()
return final
end
return export