Module:trih-pro-conj

From Linguifex
Revision as of 19:03, 6 July 2026 by Nehster9 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


-- Proto-Trihimic verb module
local p = {}

----------------------------------------------------------------
-- ENDINGS
----------------------------------------------------------------

local endings = {
    pres_part = "nā",
    past_part = "or",

    pres_1s = "a",
    pres_2s = "ad",
    pres_3s = "kt",
    pres_1p = "aka",
    pres_2p = "ada",
    pres_3p = "kta",

    imperf_1s = "eis",
    imperf_2s = "ĕis",
    imperf_3s = "ent",
    imperf_1p = "eisa",
    imperf_2p = "ĕisa",
    imperf_3p = "ekta",

    past_1s = "ir",
    past_2s = "ind",
    past_3s = "it",
    past_1p = "ira",
    past_2p = "inda",
    past_3p = "ita",

    fut_1s = "āna",
    fut_2s = "ānad",
    fut_3s = "ānakt",
    fut_1p = "ānaka",
    fut_2p = "ānada",
    fut_3p = "ānakta",

    Spres_1s = "er",
    Spres_2s = "īd",
    Spres_3s = "iōd",
    Spres_1p = "era",
    Spres_2p = "īda",
    Spres_3p = "iōda",

    Simperf_1s = "au",
    Simperf_2s = "ōplą",
    Simperf_3s = "in",
    Simperf_1p = "awa",
    Simperf_2p = "ōpla",
    Simperf_3p = "ina",
    
    Opres_1s = "ŏid",
    Opres_2s = "anas",
    Opres_3s = "ăudi",
    Opres_1p = "ŏida",
    Opres_2p = "anasa",
    Opres_3p = "ăudia",

    Oimperf_1s = "ūd",
    Oimperf_2s = "oll",
    Oimperf_3s = "ŏt",
    Oimperf_1p = "ūda",
    Oimperf_2p = "olla",
    Oimperf_3p = "ŏta",

    IMP_2s = "s",
    IMP_3s = "ert",
    IMP_2p = "sa",
    IMP_3p = "erta",
}

----------------------------------------------------------------
-- IRREGULAR VERBS
----------------------------------------------------------------

local irregulars = {
	[""] = {
		
	}
}

----------------------------------------------------------------
-- STEM
----------------------------------------------------------------

local function get_stem(title)
    return mw.ustring.gsub(title, "áną$", "")
end

----------------------------------------------------------------
-- DISPLAY HELPERS
----------------------------------------------------------------

local function make_cell(form, prefix)
    if not form then return "—" end
    if prefix then form = prefix .. " " .. form end

    return "<div style='text-align:center;'>"
        .. "" .. form .. ""
        .. "</div>"
end

local function make_pronoun(text)
    return text
end

local function empty_cell()
    return "<div style='text-align:center;'>—</div>"
end

----------------------------------------------------------------
-- COMBINE
----------------------------------------------------------------

local function combine(stem, ending)

    local form = stem .. ending

    ----------------------------------------------------------------
    -- PHONOLOGICAL RULES
    ----------------------------------------------------------------

    -- double h is simplified to single h
    form = mw.ustring.gsub(form, "hh", "h")
    
    -- double i is simplified to single long i
    form = mw.ustring.gsub(form, "[iī][iī]", "ī")

    return form
end

----------------------------------------------------------------
-- MAIN FUNCTION
----------------------------------------------------------------

function p.show(frame)

    local args = frame:getParent().args
    local title = mw.title.getCurrentTitle().text

    local stem = get_stem(title)
    local root = args.root

    local strong = args.strong
    local strong_classes = {
    a = {
        past = "ū",
        future = "ō",
    },
    
    e = {
        past = "ṑ",
        future = "i",
    },
    
    o = {
        past = "ē",
        future = "ā",
    },
}

local strong_categories = {
    a = "Proto-Trihimic class 1 strong verbs",
    e = "Proto-Trihimic class 2 strong verbs",
    o = "Proto-Trihimic class 3 strong verbs",
}

    local forms = {}

	local used_irregular = false

    for slot, ending in pairs(endings) do

        if args[slot] and args[slot] ~= "" then
            forms[slot] = args[slot]

        elseif irregulars[title] and irregulars[title][slot] then
            forms[slot] = irregulars[title][slot]
            used_irregular = true

        else
            local currentStem = stem

			local rootPart = root
			local suffixPart = ""

			if rootPart then
			 suffixPart = mw.ustring.sub(stem, mw.ustring.len(rootPart) + 1)
			end

-- STRONG VERBS
if strong and strong_classes[strong] then

    local grade

    if mw.ustring.match(slot, "^past_") then
        grade = strong_classes[strong].past

    elseif mw.ustring.match(slot, "^fut_") then
        grade = strong_classes[strong].future
    end

    if grade then
        if rootPart then
            rootPart = mw.ustring.gsub(rootPart, strong, grade)
            currentStem = rootPart .. suffixPart
        else
            currentStem = mw.ustring.gsub(currentStem, strong, grade)
        end
    end
end

            forms[slot] = combine(currentStem, ending)
        end
    end

local conjugation_type

if strong_categories[strong] then
    conjugation_type = " (strong class " .. strong_categories[strong]:match("class (%d+)") .. ")"
else
    conjugation_type = " (weak)"
end

    ----------------------------------------------------------------
    -- TABLE OUTPUT
    ----------------------------------------------------------------

    local t = {}

    table.insert(t,
    '{| class="wikitable mw-collapsible mw-collapsed"\n'
    .. '|+ Conjugation of [[Contionary:' .. title .. '|' .. title .. ']]'
    .. conjugation_type .. '\n'
	)

    table.insert(t,
    '|-\n'
    .. '! colspan="5" style="background:#ebe8b9;" | Infinitive\n'
    .. '| colspan="3" | ' .. make_cell(title) .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! colspan="5" style="background:#ebe8b9;" | Present Participle\n'
    .. '| colspan="3" | ' .. make_cell(forms.pres_part or "—") .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! colspan="5" style="background:#ebe8b9;" | Past Participle\n'
    .. '| colspan="3" | ' .. make_cell(forms.past_part or "—") .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! colspan="2" rowspan="2" style="background:#cfcfcf;" | !! colspan="3" style="background:#cfcfcf;" | Singular !! colspan="3" style="background:#cfcfcf;" | Plural\n'
    )

    table.insert(t,
    '|-\n'
    .. '! style="background:#cfcfcf;" | 1st !! style="background:#cfcfcf;" | 2nd !! style="background:#cfcfcf;" | 3rd !! style="background:#cfcfcf;" | 1st !! style="background:#cfcfcf;" | 2nd !! style="background:#cfcfcf;" | 3rd\n'
    )

    table.insert(t,
    '|-\n'
    .. '! rowspan="5" style="background:#bbd0fa;" | Indicative\n'
    .. '! \n'
    .. '! ' .. make_pronoun("wey")
    .. ' !! ' .. make_pronoun("tífus")
    .. ' !! ' .. make_pronoun("wēs/liw/kew")
    .. ' !! ' .. make_pronoun("wéya")
    .. ' !! ' .. make_pronoun("tifúsa")
    .. ' !! ' .. make_pronoun("wēsa")
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Present\n'
    .. '| ' .. make_cell(forms.pres_1s)
    .. ' || ' .. make_cell(forms.pres_2s)
    .. ' || ' .. make_cell(forms.pres_3s)
    .. ' || ' .. make_cell(forms.pres_1p)
    .. ' || ' .. make_cell(forms.pres_2p)
    .. ' || ' .. make_cell(forms.pres_3p)
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Imperfect\n'
    .. '| ' .. make_cell(forms.imperf_1s)
    .. ' || ' .. make_cell(forms.imperf_2s)
    .. ' || ' .. make_cell(forms.imperf_3s)
    .. ' || ' .. make_cell(forms.imperf_1p)
    .. ' || ' .. make_cell(forms.imperf_2p)
    .. ' || ' .. make_cell(forms.imperf_3p)
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Past\n'
    .. '| ' .. make_cell(forms.past_1s)
    .. ' || ' .. make_cell(forms.past_2s)
    .. ' || ' .. make_cell(forms.past_3s)
    .. ' || ' .. make_cell(forms.past_1p)
    .. ' || ' .. make_cell(forms.past_2p)
    .. ' || ' .. make_cell(forms.past_3p)
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Future\n'
    .. '| ' .. make_cell(forms.fut_1s)
    .. ' || ' .. make_cell(forms.fut_2s)
    .. ' || ' .. make_cell(forms.fut_3s)
    .. ' || ' .. make_cell(forms.fut_1p)
    .. ' || ' .. make_cell(forms.fut_2p)
    .. ' || ' .. make_cell(forms.fut_3p)
    .. '\n'
    .. '|-\n'
    .. '| colspan="8" style="background:#cfcfcf; height:6px; padding:0;" | \n'
    )

    table.insert(t,
    '|-\n'
    .. '! rowspan="3" style="background:#b3da9d;" | Subjunctive\n'
    .. '! \n'
    .. '! ' .. make_pronoun("wey")
    .. ' !! ' .. make_pronoun("tífus")
    .. ' !! ' .. make_pronoun("wēs/liw/kew")
    .. ' !! ' .. make_pronoun("wéya")
    .. ' !! ' .. make_pronoun("tifúsa")
    .. ' !! ' .. make_pronoun("wēsa")
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Present\n'
    .. '| ' .. make_cell(forms.Spres_1s)
    .. ' || ' .. make_cell(forms.Spres_2s)
    .. ' || ' .. make_cell(forms.Spres_3s)
    .. ' || ' .. make_cell(forms.Spres_1p)
    .. ' || ' .. make_cell(forms.Spres_2p)
    .. ' || ' .. make_cell(forms.Spres_3p)
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Imperfect\n'
    .. '| ' .. make_cell(forms.Simperf_1s)
    .. ' || ' .. make_cell(forms.Simperf_2s)
    .. ' || ' .. make_cell(forms.Simperf_3s)
    .. ' || ' .. make_cell(forms.Simperf_1p)
    .. ' || ' .. make_cell(forms.Simperf_2p)
    .. ' || ' .. make_cell(forms.Simperf_3p)
    .. '\n'
    .. '|-\n'
    .. '| colspan="8" style="background:#cfcfcf; height:6px; padding:0;" | \n'
    )
    
    table.insert(t,
    '|-\n'
    .. '! rowspan="3" style="background:#9cd9c1;" | Optative\n'
    .. '! \n'
    .. '! ' .. make_pronoun("wey")
    .. ' !! ' .. make_pronoun("tífus")
    .. ' !! ' .. make_pronoun("wēs/liw/kew")
    .. ' !! ' .. make_pronoun("wéya")
    .. ' !! ' .. make_pronoun("tifúsa")
    .. ' !! ' .. make_pronoun("wēsa")
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Present\n'
    .. '| ' .. make_cell(forms.Opres_1s)
    .. ' || ' .. make_cell(forms.Opres_2s)
    .. ' || ' .. make_cell(forms.Opres_3s)
    .. ' || ' .. make_cell(forms.Opres_1p)
    .. ' || ' .. make_cell(forms.Opres_2p)
    .. ' || ' .. make_cell(forms.Opres_3p)
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Imperfect\n'
    .. '| ' .. make_cell(forms.Oimperf_1s)
    .. ' || ' .. make_cell(forms.Oimperf_2s)
    .. ' || ' .. make_cell(forms.Oimperf_3s)
    .. ' || ' .. make_cell(forms.Oimperf_1p)
    .. ' || ' .. make_cell(forms.Oimperf_2p)
    .. ' || ' .. make_cell(forms.Oimperf_3p)
    .. '\n'
    .. '|-\n'
    .. '| colspan="8" style="background:#cfcfcf; height:6px; padding:0;" | \n'
    )

    table.insert(t,
    '|-\n'
    .. '! rowspan="3" style="background:#e8cc8f;" | Imperative\n'
    .. '! \n'
    .. '! —'
    .. ' !! ' .. make_pronoun("tífus")
    .. ' !! ' .. make_pronoun("wēs/liw/kew")
    .. ' !! —'
    .. ' !! ' .. make_pronoun("tifúsa")
    .. ' !! ' .. make_pronoun("wēsa")
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Affirmative\n'
    .. '| ' .. empty_cell()
    .. ' || ' .. make_cell(forms.IMP_2s)
    .. ' || ' .. make_cell(forms.IMP_3s)
    .. ' || ' .. empty_cell()
    .. ' || ' .. make_cell(forms.IMP_2p)
    .. ' || ' .. make_cell(forms.IMP_3p)
    .. '\n'
    )

    table.insert(t,
    '|-\n'
    .. '! Negative\n'
    .. '| ' .. empty_cell()
    .. ' || ' .. make_cell(forms.IMP_2s, "ne")
    .. ' || ' .. make_cell(forms.IMP_3s, "ne")
    .. ' || ' .. empty_cell()
    .. ' || ' .. make_cell(forms.IMP_2p, "ne")
    .. ' || ' .. make_cell(forms.IMP_3p, "ne")
    .. '\n'
    )

    table.insert(t, '|}')

if strong_categories[strong] then
    table.insert(t,
        "\n[[Category:" .. strong_categories[strong] .. "]]")
        else
    table.insert(t,
        "\n[[Category:Proto-Trihimic weak verbs]]")
end

if used_irregular then
    table.insert(t,
        "\n[[Category:Proto-Trihimic irregular verbs]]")
end

return table.concat(t)
end

return p