local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local m_common = require("Module:ine-common")
local export = {}
local lang = require("Module:languages").getByCode("ine-pro")
local endings = {
= {
= {athem = {"mi"}, them = {"h₂"}},
= {"si"},
= {"ti"},
= {"wós"},
= {"tés"},
= {"tés"},
= {"mós"},
= {"té"},
= {{stressed = "énti", unstressed = "n̥ti"}},
},
= {
= {"m̥"},
= {"s"},
= {"t"},
= {"wé"},
= {"tóm"},
= {"tā́m"},
= {"mé"},
= {"té"},
= {{stressed = "ént", unstressed = "n̥t"}},
},
= {
= {athem = {"", "dʰí"}, them = {""}},
= {"tu"},
= {"tóm"},
= {"tā́m"},
= {"té"},
= {{stressed = "éntu", unstressed = "n̥tu"}},
},
= {
= {"h₂ér"},
= {"th₂ér"},
= {athem = {"tór", "ór"}, them = {"tór"}},
= {"wósdʰh₂"},
= "?",
= "?",
= {"mósdʰh₂"},
= {"dʰh₂wé"},
= {"rór", "n̥tór"},
},
= {
= {"h₂é"},
= {"th₂é"},
= {athem = {"tó", "ó"}, them = {"tó"}},
= {"wédʰh₂"},
= "?",
= "?",
= {"médʰh₂"},
= {"dʰh₂wé"},
= {"ró", "n̥tó"},
},
= {
= {"só"},
= "?",
= "?",
= "?",
= {"dʰh₂wé"},
= "?",
},
= {
= {"h₂e"},
= {"th₂e"},
= {"e"},
= {"wé"},
= "?",
= "?",
= {"mé"},
= {"é"},
= {"ḗr"},
},
}
local them_vowel = {
= "ó",
= "é",
= "é",
= "ó",
= "é",
= "é",
= "ó",
= "é",
= "ó",
}
local function inflect(data, prefix, endings, stem1, stem2)
stem2 = stem2 or stem1
-- Is the stem thematic?
local them = mw.clone(them_vowel)
if mw.ustring.find(stem1, "$") then
if mw.ustring.find(stem1, "$") then
for key, val in pairs(them) do
them = m_common.lengthen(val)
end
end
if mw.ustring.find(stem1, "$") then
for key, val in pairs(them) do
them = m_common.destress(val)
end
end
stem1 = mw.ustring.gsub(stem1, "$", "")
stem2 = stem1
else
for key, val in pairs(them) do
them = ""
end
end
-- Go over each person-number combination
for p, pendings in pairs(endings) do
if pendings == "?" then
data.forms = {"?"}
elseif pendings then
data.forms = {}
if pendings.athem then
if them == "" then
pendings = pendings.athem
else
pendings = pendings.them
end
end
for _, pending in ipairs(pendings) do
local stem = stem1
-- Use stem2 if the ending can be stressed, stem1 otherwise
if pending.stressed or mw.ustring.find(pending, "") then
stem = stem2
end
local ending
local ending_unstr
-- Thematic endings are never stressed
if them ~= "" then
ending = pending.unstressed or m_common.destress(pending.stressed or pending)
else
ending = pending.stressed or pending
ending_unstr = pending.unstressed
end
table.insert(data.forms, m_common.add_ending(stem .. them, ending, ending_unstr))
end
end
end
end
function export.eventive(frame)
local params = {
= {required = true},
= {},
= {},
= {}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
if mw.title.getCurrentTitle().nsText == "Template" then
args = args or (frame.args == "impf" and "linékʷ" or "léykʷ")
args = args or (frame.args == "impf" and "linkʷ" or "likʷ")
end
args = args or args
local data = {forms = {}, title = nil, categories = {}}
data.info = (frame.args == "impf" and "Imperfective" or "Perfective")
if mw.ustring.find(args, "$") then
data.info = data.info .. ", thematic"
else
data.info = data.info .. ", athematic"
end
data.v = args
if data.v == "actv" then
data.info = data.info .. ", active only"
elseif data.v == "midl" then
data.info = data.info .. ", middle only"
end
local subj_stem, opta_stem1, opta_stem2
-- Is the stem thematic?
if mw.ustring.find(args, "$") then
subj_stem = mw.ustring.gsub(args, "()$", { = "ē", = "ō", = "ḗ", = "ṓ"})
opta_stem1 = mw.ustring.gsub(args, "()$", { = "oyh₁", = "oyh₁", = "óyh₁", = "óyh₁"})
opta_stem2 = opta_stem1
else
subj_stem = args .. "e"
opta_stem1 = m_common.add_ending(args, "yéh₁")
opta_stem2 = m_common.add_ending(args, "ih₁")
end
-- Create the forms
if frame.args == "impf" then
data.tenses = true
inflect(data, "pres_indc_actv", endings, args, args)
inflect(data, "past_indc_actv", endings, args, args)
inflect(data, "pres_indc_midl", endings, args, args)
inflect(data, "past_indc_midl", endings, args, args)
local suffix_type
if mw.ustring.find(args, "$") then
if mw.ustring.find(mw.ustring.sub(args, 1, -2), "") then
if mw.ustring.find(args, "o.+éye$") then
--Removed, redundant to ]
--suffix_type = " eye-causative/iterative"
elseif mw.ustring.find(args, "é.+ye$") then
suffix_type = " ye-present"
elseif mw.ustring.find(args, ".+yé$") then
suffix_type = " ye-denominative"
elseif mw.ustring.find(args, "é.+dʰh₁e$") then
suffix_type = " dʰh₁e-present"
else
suffix_type = " root thematic"
end
else
if mw.ustring.find(args, "sḱé$") then
suffix_type = " sḱe-present"
elseif mw.ustring.find(args, "syé$") then
suffix_type = " sye-desiderative"
elseif mw.ustring.find(args, "yé$") then
suffix_type = " zero-grade ye-present"
elseif mw.ustring.find(args, "í.+e$") then
suffix_type = " i-reduplicated root thematic"
else
suffix_type = " zero-grade root thematic"
end
end
else
if args == "eh1" then
suffix_type = " eh₁-stative"
elseif mw.ustring.find(args, "néw$") then
suffix_type = " nu-present"
elseif mw.ustring.find(args, "né") and not mw.ustring.find(args, "né") then
suffix_type = " nasal-infixed present"
elseif mw.ustring.find(args, "í.+e.+") and not mw.ustring.find(args, "í.+e.+") then
suffix_type = " i-reduplicated root athematic"
elseif mw.ustring.find(args, "é.+e.+") and not mw.ustring.find(args, "é.+e.+") then
suffix_type = " reduplicated root athematic"
elseif mw.ustring.find(args, "ḗ") then
suffix_type = " lengthened-grade root athematic"
else
suffix_type = " root athematic"
end
end
if suffix_type then
table.insert(data.categories, lang:getCanonicalName() .. suffix_type .. " verbs")
end
else
inflect(data, "indc_actv", endings, args, args)
inflect(data, "indc_midl", endings, args, args)
local suffix_type = {}
if mw.ustring.find(args, "$") then
if not mw.ustring.find(mw.ustring.sub(args, 1, -2), "") then
suffix_type = " zero-grade root thematic aorist"
elseif mw.ustring.find(args, "é.+e$") and mw.ustring.find(args, "é.+e$") then
suffix_type = " reduplicated root thematic aorist"
else
suffix_type = " root thematic aorist"
end
else
if mw.ustring.find(args, "ḗ.+s$") then
suffix_type = " s-aorist"
elseif not mw.ustring.find(args, "") then
suffix_type = " zero-grade root athematic aorist"
elseif mw.ustring.find(args, "é.+") and mw.ustring.find(args, "é.+") then
suffix_type = " reduplicated root athematic aorist"
else
suffix_type = " root athematic aorist"
end
end
table.insert(data.categories, lang:getCanonicalName() .. suffix_type .. " verbs")
end
inflect(data, "impr_actv", endings, args, args)
inflect(data, "subj_actv", endings, subj_stem)
inflect(data, "opta_actv", endings, opta_stem1, opta_stem2)
inflect(data, "impr_midl", endings, args, args)
inflect(data, "subj_midl", endings, subj_stem)
inflect(data, "opta_midl", endings, opta_stem2, opta_stem2)
local o_grade = mw.ustring.gsub(args, "$", { = "o", = "ó"})
data.forms = {m_common.add_ending(o_grade, "ónts", "n̥ts")}
data.forms = {m_common.add_ending(o_grade, "m̥h₁nós")}
return make_table(data)
end
function export.stative(frame)
local params = {
= {required = true},
= {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
if mw.title.getCurrentTitle().nsText == "Template" then
args = args or "lelóykʷ"
args = args or "lelikʷ"
end
args = args or args
local data = {forms = {}, title = nil, categories = {}}
data.info = "Stative"
data.v = "actv"
local subj_stem, opta_stem1, opta_stem2
-- Is the stem thematic?
if mw.ustring.find(args, "$") then
error("Stative verbs must be athematic.")
else
subj_stem = mw.ustring.gsub(args, "ó", "é") .. "e"
opta_stem1 = m_common.add_ending(args, "yéh₁")
opta_stem2 = m_common.add_ending(args, "ih₁")
end
-- Create the forms
inflect(data, "indc_actv", endings, args, args)
inflect(data, "impr_actv", endings, args, args)
inflect(data, "subj_actv", endings, subj_stem)
inflect(data, "opta_actv", endings, opta_stem1, opta_stem2)
data.forms = {m_common.add_ending(args, "wṓs")}
local suffix_type = {}
if mw.ustring.find(args, "e.+ó.+") and not mw.ustring.find(args, "e.+ó.+") then
suffix_type = " reduplicated root perfect"
else
suffix_type = " root perfect"
end
table.insert(data.categories, lang:getCanonicalName() .. suffix_type .. " verbs")
return make_table(data)
end
local names = {
= "Active voice",
= "Middle voice",
= "Indicative",
= "Present indicative",
= "Past indicative",
= "Imperative",
= "Subjunctive",
= "Optative",
= "1st singular",
= "2nd singular",
= "3rd singular",
= "1st dual",
= "2nd dual",
= "3rd dual",
= "1st plural",
= "2nd plural",
= "3rd plural",
}
-- Make the table
function make_table(data)
local function show_form(form)
if not form then
return "—"
end
if type(form) ~= "table" then
error("a non-table value was given in the list of inflected forms.")
end
local ret = {}
for key, subform in ipairs(form) do
table.insert(ret, m_links.full_link({lang = lang, alt = "*" .. subform}))
end
return table.concat(ret, ", ")
end
local function repl(param)
if param == "lemma" then
return m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
elseif param == "info" then
return data.info or ""
else
return show_form(data.forms)
end
end
local voices = data.v and {data.v} or {"actv", "midl"}
local moods = data.tenses and {"pres_indc", "past_indc", "impr", "subj", "opta"} or {"indc", "impr", "subj", "opta"}
local wikicode = {}
table.insert(wikicode, "{| class=\"inflection-table vsSwitcher\" data-toggle-category=\"inflection\" style=\"background: #FAFAFA; border: 1px solid #d0d0d0; text-align: left;\" cellspacing=\"1\" cellpadding=\"2\"")
table.insert(wikicode, "|- style=\"background: #CCCCFF;\"\n! class=\"vsToggleElement\" colspan=\"" .. (#moods + 1) .. "\" | {{{info}}}")
table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"min-width: 8em; background: #E6E6FF;\" | " .. names .. "\n| style=\"min-width: 11em;\" | {{{" .. (data.tenses and "pres_indc" or "indc") .. "_" .. (data.v or "actv") .. "_3sg}}}")
table.insert(wikicode, "|- class=\"vsShow\" style=\"background: #F2F2FF;\"")
table.insert(wikicode, "! style=\"min-width: 8em; background: #E6E6FF;\" | " .. names .. "\n| style=\"min-width: 11em;\" | {{{" .. (data.tenses and "pres_indc" or "indc") .. "_" .. (data.v or "actv") .. "_3pl}}}")
for _, voice in ipairs(voices) do
table.insert(wikicode, "|- class=\"vsHide\" style=\"background: #CCCCFF;\"\n! " .. names)
for _, mood in ipairs(moods) do
table.insert(wikicode, "! style=\"min-width: 11em; background: #CCCCFF;\" | " .. names)
end
for _, pn in ipairs({"1sg", "2sg", "3sg", "1du", "2du", "3du", "1pl", "2pl", "3pl"}) do
table.insert(wikicode, "|- class=\"vsHide\" style=\"background-color: #F2F2FF;\"\n! style=\"min-width: 8em; background-color: #E6E6FF;\" | " .. names)
for _, mood in ipairs(moods) do
table.insert(wikicode, "| {{{" .. mood .. "_" .. voice .. "_" .. pn .. "}}}")
end
end
table.insert(wikicode, "|- class=\"vsHide\" style=\"background-color: #CCCCFF;\"\n| colspan=\"" .. (#moods + 1) .. "\" |")
table.insert(wikicode, "|- class=\"vsHide\" style=\"background-color: #F2F2FF;\"\n! style=\"background-color: #E6E6FF;\" | Participle")
table.insert(wikicode, "| {{{" .. voice .. "_ptcp}}}")
table.insert(wikicode, "| style=\"background-color: #CCCCFF;\" colspan=\"" .. (#moods - 1) .. "\" |")
end
table.insert(wikicode, =])
wikicode = table.concat(wikicode, "\n")
return (mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)) .. m_utilities.format_categories(data.categories, lang)
end
return export