Module:Ts-conjugate
Documentation for this module may be created at Module:Ts-conjugate/doc
local p = {};
local PAST_VOWELS = {a = "e", e = "e", i = "i", o = "o", u = "o"}
local PRESENT_VOWELS = {a = "a", e = "e", i = "i", o = "o", u = "u"}
local FUTURE_VOWELS = {a = "a", e = "e", i = "e", o = "e", u = "u"}
local NONFINITE_VOWELS = {a = "a", e = "e", i = "i", o = "o", u = "o"}
local LONG_VOWELS = {a = "ā", e = "ē", i = "ī", o = "ō", u = "ū"}
function p.conjugate_regular(verb, is_u)
local class = mw.ustring.sub(verb, -2, -2)
-- regular verb must end in x
if mw.ustring.sub(verb, -1, -1) ~= "x" then
error("Invalid regular verb input")
end
-- regular verb must be in the infinitive (thus -ax -ex -ix -ox)
if not (class == "a" or class == "e" or class == "i" or class == "o") then
error("Invalid verb class (must be a/e/i/o")
end
if is_u then
if class == "o" then
class = "u"
else
error("is_u only allowed on -ox infinitive")
end
end
local stem = mw.ustring.sub(verb, 1, -3)
local v_pst = PAST_VOWELS[class]
local v_pres = PRESENT_VOWELS[class]
local v_fut = FUTURE_VOWELS[class]
local v_nonf = NONFINITE_VOWELS[class]
local function with(v1, v2)
if v1 == v2 then
return LONG_VOWELS[v1]
else
return v1 .. v2
end
end
-- todo: pseudo-irregularity "dangling consonant rule"
-- if the stem ends with two consonants
-- AND the conjugated affix does NOT start with a vowel
-- insert the infinitive vowel back in
-- (maybe default to "e" instead? its the standard epenthetic vowel)
-- also probably generalize this to "epenthetic vowel if the conjugation has bad consonants"
-- todo: pseudo-irregularity "CVVC" rule
-- shorten vowel if there's now an illegal CV:C
local out = {}
-- replacement for the verb class
out.verb_class = class
-- indicative mood
out.pst_pfv_ind = stem .. v_pst .. "l"
out.pst_impv_ind = stem .. v_pst .. "di"
out.pst_perf_ind = stem .. "x" .. v_pst
out.pst_hab_ind = stem .. "g" .. v_pst .. "s"
out.pst_sem_ind = stem .. "ł" .. v_pst .. "si"
out.pst_iter_ind = stem .. "ł" .. v_pst .. "dsi"
out.pres_pfv_ind = stem
out.pres_impv_ind = stem .. v_pres
out.pres_perf_ind = stem .. "b" .. v_pres
out.pres_hab_ind = stem .. "g" .. v_pres
out.pres_sem_ind = stem .. "ł" .. v_pres
out.pres_iter_ind = stem .. "ł" .. v_pres .. "ł" .. v_pres
out.fut_pfv_ind = stem .. "tw" .. v_fut
out.fut_impv_ind = stem .. v_fut .. "s"
out.fut_perf_ind = stem .. "ğ" .. v_fut
out.fut_hab_ind = stem .. "š" .. v_fut .. "s"
out.fut_sem_ind = stem .. "ł" .. with(v_fut, "a")
out.fut_iter_ind = stem .. "ł" .. v_fut .. "da"
-- subjunctive mood
out.pst_pfv_subj = stem .. LONG_VOWELS[v_pst] .. "lu"
out.pst_impv_subj = stem .. v_pst .. "dil"
out.pst_perf_subj = stem .. "x" .. v_pst .. "l"
out.pst_hab_subj = stem .. "g" .. v_pst .. "slu"
out.pst_sem_subj = stem .. "ł" .. v_pst .. "sil"
out.pst_iter_subj = stem .. "ł" .. v_pst .. "dsil"
out.pres_pfv_subj = stem .. "lu"
out.pres_impv_subj = stem .. v_pres .. "lu"
out.pres_perf_subj = stem .. "b" .. v_pres .. "l"
out.pres_hab_subj = stem .. "g" .. v_pres .. "l"
out.pres_sem_subj = stem .. "ł" .. v_pres .. "l"
out.pres_iter_subj = stem .. "ł" .. v_pres .. "l" .. v_pres
out.fut_pfv_subj = stem .. "tw" .. v_fut .. "l"
out.fut_impv_subj = stem .. v_fut .. "sul"
out.fut_perf_subj = stem .. v_fut .. "ğul"
out.fut_hab_subj = stem .. "š" .. v_fut .. "slu"
out.fut_sem_subj = stem .. "ł" .. with(v_fut, "a") .. "lu"
out.fut_iter_subj = stem .. "ł" .. v_fut .. "dalu"
-- imperative mood (wildly unfinished)
out.pres_pfv_imp = stem .. "k" .. v_pres .. "s"
-- optative mood (unfinished, half-fused)
out.pst_hab_opt = out.pst_hab_ind .. " qa"
out.pst_sem_opt = out.pst_sem_ind .. " qa"
out.pst_iter_opt = out.pst_iter_ind .. " qa"
out.pres_hab_opt = out.pres_hab_ind .. " qa"
out.pres_sem_opt = out.pres_sem_ind .. " qa"
out.pres_iter_opt = out.pres_iter_ind .. " qa"
out.fut_hab_opt = out.fut_hab_ind .. " qa"
out.fut_sem_opt = out.fut_sem_ind .. " qa"
out.fut_iter_opt = out.fut_iter_ind .. " qa"
-- nonfinite
out.nonf_inf = stem .. v_nonf .. "x"
out.nonf_pst_part = stem .. v_nonf .. "n"
out.nonf_pres_part = stem .. v_nonf .. "me"
out.nonf_fut_part = stem .. with(v_nonf, "o") .. "la"
-- converb
out.conv_prim = stem .. "eğ"
out.conv_purp = stem .. "epō"
out.conv_caus = stem .. "eš"
out.conv_sequ = stem .. "eğe"
out.conv_pfv = stem .. "eğes"
out.conv_cond = stem .. "eğut"
out.conv_impv = stem .. with(v_nonf, "e") .. "mes"
out.conv_res = stem .. v_nonf .. "lap"
out.conv_term = stem .. v_nonf .. "lał"
out.conv_immed = stem .. with(v_nonf, "e") .. "tu"
out.conv_sim = stem .. with(v_nonf, "o") .. "tu"
out.conv_inter = stem .. v_nonf .. "lšu" -- scary! might make CV:C! figure out how to deal!
out.conv_grad = stem .. v_nonf .. "ltu" -- also scary!
out.conv_ant = stem .. with(v_nonf, "o") .. "nes"
out.conv_concess = stem .. "eğutes"
out.conv_irres = stem .. v_nonf .. "lšus" -- also scary!
return out
end
function p.conjugate(verb, is_u)
-- todo: weird shit like the big three
return p.conjugate_regular(verb, is_u)
end
local BASE_TABLE = [[
{| class="mw-collapsible mw-collapsed wikitable" style="text-align:center;"
|-
! colspan="10" style="font-weight:bold;" | Verb Conjugation (verb_class-class)
|- style="font-weight:bold;"
| colspan="6" style="vertical-align:middle;" | Finite Forms
| colspan="4" | Non-Finite Forms
|- style="font-weight:bold;"
| rowspan="2" style="vertical-align:middle;" | Tense
| rowspan="2" style="vertical-align:middle;" | Aspect
| colspan="4" style="vertical-align:middle;" | Mood
| Infinitive
| style="font-weight:normal;" | nonf_inf
| Past Participle
| style="font-weight:normal;" | nonf_pst_part
|- style="font-weight:bold;"
| style="vertical-align:middle;" | Indicative
| style="vertical-align:middle;" | Subjunctive
| style="vertical-align:middle;" | Imperative
| style="vertical-align:middle;" | Optative
| Present Participle
| style="font-weight:normal;" | nonf_pres_part
| Future Participle
| style="font-weight:normal;" | nonf_fut_part
|- style="font-weight:bold;"
| rowspan="6" style="vertical-align:middle;" | Past
| style="vertical-align:middle;" | Perfective
| style="vertical-align:middle; font-weight:normal;" | pst_pfv_ind
| style="vertical-align:middle; font-weight:normal;" | pst_pfv_subj
| rowspan="6" style="vertical-align:middle; background-color:#9B9B9B; font-weight:normal;" |
| style="vertical-align:middle; font-weight:normal;" | pst_pfv_opt
| colspan="4" | Converbs
|-
| style="vertical-align:middle; font-weight:bold;" | Imperfective
| style="vertical-align:middle;" | pst_impv_ind
| style="vertical-align:middle;" | pst_impv_subj
| style="vertical-align:middle;" | pst_impv_opt
| style="font-weight:bold;" | Primary
| conv_prim
| style="font-weight:bold;" | Purposive
| conv_purp
|-
| style="vertical-align:middle; font-weight:bold;" | Perfect
| style="vertical-align:middle;" | pst_perf_ind
| style="vertical-align:middle;" | pst_perf_subj
| style="vertical-align:middle;" | pst_perf_opt
| style="font-weight:bold;" | Causative
| conv_caus
| style="font-weight:bold;" | Sequential
| conv_sequ
|-
| style="vertical-align:middle; font-weight:bold;" | Habitual
| style="vertical-align:middle;" | pst_hab_ind
| style="vertical-align:middle;" | pst_hab_subj
| style="vertical-align:middle;" | pst_hab_opt
| style="font-weight:bold;" | Perfective
| conv_pfv
| style="font-weight:bold;" | Imperfective
| conv_impv
|-
| style="vertical-align:middle; font-weight:bold;" | Semelfactive
| style="vertical-align:middle;" | pst_sem_ind
| style="vertical-align:middle;" | pst_sem_subj
| style="vertical-align:middle;" | pst_sem_opt
| style="font-weight:bold;" | Conditional
| conv_cond
| style="font-weight:bold;" | Resultative
| conv_res
|-
| style="vertical-align:middle; font-weight:bold;" | Iterative
| style="vertical-align:middle;" | pst_iter_ind
| style="vertical-align:middle;" | pst_iter_subj
| style="vertical-align:middle;" | pst_iter_opt
| style="font-weight:bold;" | Terminative
| conv_term
| style="font-weight:bold;" | Immediative
| conv_immed
|-
| rowspan="6" style="vertical-align:middle; font-weight:bold;" | Present
| style="vertical-align:middle; font-weight:bold;" | Perfective
| pres_pfv_ind
| pres_pfv_subj
| style="vertical-align:middle;" | pres_pfv_imp
| pres_pfv_opt
| style="font-weight:bold;" | Similative
| conv_sim
| style="font-weight:bold;" | Interruptive
| conv_inter
|-
| style="vertical-align:middle; font-weight:bold;" | Imperfective
| pres_impv_ind
| pres_impv_subj
| style="vertical-align:middle;" | pres_impv_imp
| pres_impv_opt
| style="font-weight:bold;" | Gradientive
| conv_grad
| style="font-weight:bold;" | Anterior
| conv_ant
|-
| style="vertical-align:middle; font-weight:bold;" | Perfect
| pres_perf_ind
| pres_perf_subj
| style="vertical-align:middle;" | pres_perf_imp
| pres_perf_opt
| style="font-weight:bold;" | Concessive
| conv_concess
| style="font-weight:bold;" | Irresultative
| conv_irres
|-
| style="vertical-align:middle; font-weight:bold;" | Habitual
| pres_hab_ind
| pres_hab_subj
| style="vertical-align:middle;" | pres_hab_imp
| pres_hab_opt
| rowspan="9" colspan="4" |
|-
| style="vertical-align:middle; font-weight:bold;" | Semelfactive
| pres_sem_ind
| pres_sem_subj
| style="vertical-align:middle;" | pres_sem_imp
| pres_sem_opt
|-
| style="vertical-align:middle; font-weight:bold;" | Iterative
| pres_iter_ind
| pres_iter_subj
| style="vertical-align:middle;" | pres_iter_imp
| pres_iter_opt
|-
| rowspan="6" style="vertical-align:middle; font-weight:bold;" | Future
| style="vertical-align:middle; font-weight:bold;" | Perfective
| fut_pfv_ind
| fut_pfv_subj
| style="vertical-align:middle;" | fut_pfv_imp
| fut_pfv_opt
|-
| style="vertical-align:middle; font-weight:bold;" | Imperfective
| fut_impv_ind
| fut_impv_subj
| style="vertical-align:middle;" | fut_impv_imp
| fut_impv_opt
|-
| style="vertical-align:middle; font-weight:bold;" | Perfect
| fut_perf_ind
| fut_perf_subj
| style="vertical-align:middle;" | fut_perf_imp
| fut_perf_opt
|-
| style="vertical-align:middle; font-weight:bold;" | Usitative
| fut_hab_ind
| fut_hab_subj
| style="vertical-align:middle;" | fut_hab_imp
| fut_hab_opt
|-
| style="vertical-align:middle; font-weight:bold;" | Semeliterative
| fut_sem_ind
| fut_sem_subj
| style="vertical-align:middle;" | fut_sem_imp
| fut_sem_opt
|-
| style="vertical-align:middle; font-weight:bold;" | Iterative
| fut_iter_ind
| fut_iter_subj
| style="vertical-align:middle;" | fut_iter_imp
| fut_iter_opt
|}
]]
function p.make_conjugation_table(verb, is_u)
local conj = p.conjugate(verb, is_u)
local out = BASE_TABLE
for template,form in pairs(conj) do
out = mw.ustring.gsub(out, template, form)
end
return out
end
return p