सामग्री पर जाएँ

मॉड्यूल:sa-verb/data

विक्षनरी से

इस मॉड्यूल हेतु प्रलेख मॉड्यूल:sa-verb/data/doc पर बनाया जा सकता है

-- This is a data module for [[Module:sa-verb]].

local export = {}

local sa_utils = require("Module:sa-utilities")

local sub = mw.ustring.sub
local match = mw.ustring.match
local split = mw.text.split

local function split_xs(form)
    if form == nil then
        return nil
    end
    local s = split(form, "<")
    if s[2] ~= nil then
        local sanitized_s2 = sub(s[2], 1, -2)
        return {s[1], sanitized_s2}
    else
        return {form, nil}
    end
end

local function ssub(form, s, e)
    local splt = split_xs(form)
    local _, stem = splt[1], splt[2]
    if stem == nil then
        return sub(form, s, e)
    else
        return stem
    end
end

local function zsub(form, s)
    local splt = split_xs(form)
    local lemma, _ = splt[1], splt[2]
    return sub(lemma, s)
end

local thematic_tense_moods = {
    ["pres"] = {
        ["indic"] = {
            ["av"] = {
                ["1-s"] = "Ami",
                ["2-s"] = "asi",
                ["3-s"] = "ati",
                ["1-d"] = "AvaH",
                ["2-d"] = "aTaH",
                ["3-d"] = "ataH",
                ["1-p"] = "AmaH",
                ["2-p"] = "aTa",
                ["3-p"] = "anti"
            },
            ["mv"] = {
                ["1-s"] = "e",
                ["2-s"] = "ase",
                ["3-s"] = "ate",
                ["1-d"] = "Avahe",
                ["2-d"] = "eTe",
                ["3-d"] = "ete",
                ["1-p"] = "Amahe",
                ["2-p"] = "aDve",
                ["3-p"] = "ante"
            },
            ["pv"] = {
                ["1-s"] = "ye",
                ["2-s"] = "yase",
                ["3-s"] = "yate",
                ["1-d"] = "yAvahe",
                ["2-d"] = "yeTe",
                ["3-d"] = "yete",
                ["1-p"] = "yAmahe",
                ["2-p"] = "yaDve",
                ["3-p"] = "yante"
            }
        },
        ["imper"] = {
            ["av"] = {
                ["1-s"] = "Ani",
                ["2-s"] = {"a", "atAt"},
                ["3-s"] = {"atu", "atAt"},
                ["1-d"] = "Ava",
                ["2-d"] = "atam",
                ["3-d"] = "atAm",
                ["1-p"] = "Ama",
                ["2-p"] = "ata",
                ["3-p"] = "antu"
            },
            ["mv"] = {
                ["1-s"] = "E",
                ["2-s"] = "asva",
                ["3-s"] = "atAm",
                ["1-d"] = "AvahE",
                ["2-d"] = "eTAm",
                ["3-d"] = "etAm",
                ["1-p"] = "AmahE",
                ["2-p"] = "aDvam",
                ["3-p"] = "antam"
            },
            ["pv"] = {
                ["1-s"] = "yE",
                ["2-s"] = "yasva",
                ["3-s"] = "yatAm",
                ["1-d"] = "yAvahE",
                ["2-d"] = "yeTAm",
                ["3-d"] = "yetAm",
                ["1-p"] = "yAmahE",
                ["2-p"] = "yaDvam",
                ["3-p"] = "yantam"
            }
        },
        ["optat"] = {
            ["av"] = {
                ["1-s"] = "eyam",
                ["2-s"] = "eH",
                ["3-s"] = "et",
                ["1-d"] = "eva",
                ["2-d"] = "etam",
                ["3-d"] = "etAm",
                ["1-p"] = "emaH",
                ["2-p"] = "eta",
                ["3-p"] = "eyuH"
            },
            ["mv"] = {
                ["1-s"] = "eya",
                ["2-s"] = "eTAH",
                ["3-s"] = "eta",
                ["1-d"] = "evahi",
                ["2-d"] = "eyATAm",
                ["3-d"] = "eyAtAm",
                ["1-p"] = "emahi",
                ["2-p"] = "eDvam",
                ["3-p"] = "eran"
            },
            ["pv"] = {
                ["1-s"] = "yeya",
                ["2-s"] = "yeTAH",
                ["3-s"] = "yeta",
                ["1-d"] = "yevahi",
                ["2-d"] = "yeyATAm",
                ["3-d"] = "yeyAtAm",
                ["1-p"] = "yemahi",
                ["2-p"] = "yeDvam",
                ["3-p"] = "yeran"
            }
        },
        ["part"] = {
            ["av"] = {"ant", "at"},
            ["mv"] = "amAna",
            ["pv"] = "yamAna"
        }
    },
    ["impf"] = {
        ["indic"] = {
            ["av"] = {
                ["1-s"] = "am",
                ["2-s"] = "aH",
                ["3-s"] = "at",
                ["1-d"] = "Ava",
                ["2-d"] = "atam",
                ["3-d"] = "atAm",
                ["1-p"] = "Ama",
                ["2-p"] = "ata",
                ["3-p"] = "an"
            },
            ["mv"] = {
                ["1-s"] = "e",
                ["2-s"] = "aTAH",
                ["3-s"] = "ata",
                ["1-d"] = "Avahi",
                ["2-d"] = "eTAm",
                ["3-d"] = "etAm",
                ["1-p"] = "Amahi",
                ["2-p"] = "aDvam",
                ["3-p"] = "anta"
            },
            ["pv"] = {
                ["1-s"] = "ye",
                ["2-s"] = "yaTAH",
                ["3-s"] = "yata",
                ["1-d"] = "yAvahi",
                ["2-d"] = "yeTAm",
                ["3-d"] = "yetAm",
                ["1-p"] = "yAmahi",
                ["2-p"] = "yaDvam",
                ["3-p"] = "yanta"
            }
        }
    },
    ["fut"] = {
        ["simple"] = {
            ["av"] = {
                ["1-s"] = "syAmi",
                ["2-s"] = "syasi",
                ["3-s"] = "syati",
                ["1-d"] = "syAvaH",
                ["2-d"] = "syaTaH",
                ["3-d"] = "syataH",
                ["1-p"] = "syAmaH",
                ["2-p"] = "syaTa",
                ["3-p"] = "syanti"
            },
            ["mv"] = {
                ["1-s"] = "sye",
                ["2-s"] = "syase",
                ["3-s"] = "syate",
                ["1-d"] = "syAvahe",
                ["2-d"] = "syeTe",
                ["3-d"] = "syete",
                ["1-p"] = "syAmahe",
                ["2-p"] = "syaDve",
                ["3-p"] = "syante"
            }
        },
        ["periph"] = {
            ["av"] = {
                ["1-s"] = "tAsmi",
                ["2-s"] = "tAsi",
                ["3-s"] = "tA",
                ["1-d"] = "tAsvaH",
                ["2-d"] = "tAsTaH",
                ["3-d"] = "tArO",
                ["1-p"] = "tAsmaH",
                ["2-p"] = "tAsTa",
                ["3-p"] = "tAraH"
            }
            -- ["mv"] = {
            --     ["1-s"] = "-",
            --     ["2-s"] = "-",
            --     ["3-s"] = "-",
            --     ["1-d"] = "-",
            --     ["2-d"] = "-",
            --     ["3-d"] = "-",
            --     ["1-p"] = "-",
            --     ["2-p"] = "-",
            --     ["3-p"] = "-",
            -- },
        },
        ["part"] = {
            ["av"] = {"syant", "syat"},
            ["mv"] = "syAna"
        }
    },
    ["cond"] = {
        ["indic"] = {
            ["av"] = {
                ["1-s"] = "syam",
                ["2-s"] = "syaH",
                ["3-s"] = "syat",
                ["1-d"] = "syAva",
                ["2-d"] = "syatam",
                ["3-d"] = "syatAm",
                ["1-p"] = "syAma",
                ["2-p"] = "syata",
                ["3-p"] = "syan"
            },
            ["mv"] = {
                ["1-s"] = "sye",
                ["2-s"] = "syaTAH",
                ["3-s"] = "syata",
                ["1-d"] = "syAvahi",
                ["2-d"] = "syeTAm",
                ["3-d"] = "syetAm",
                ["1-p"] = "syAmahi",
                ["2-p"] = "syaDvam",
                ["3-p"] = "syanta"
            }
        }
    },
    ["aor"] = {
        ["indic"] = {
            ["av"] = {
                ["iṣ"] = {
                    ["1-s"] = "sam",
                    ["2-s"] = "IH",
                    ["3-s"] = "It",
                    ["1-d"] = "sva",
                    ["2-d"] = "stam",
                    ["3-d"] = "stAm",
                    ["1-p"] = "sma",
                    ["2-p"] = "sta",
                    ["3-p"] = "suH"
                },
                ["ṣ"] = {
                    ["1-s"] = "sam",
                    ["2-s"] = "sIH",
                    ["3-s"] = "sIt",
                    ["1-d"] = "sva",
                    ["2-d"] = "stam",
                    ["3-d"] = "stAm",
                    ["1-p"] = "sma",
                    ["2-p"] = "sta",
                    ["3-p"] = "suH"
                },
                ["root"] = {
                    ["1-s"] = "am",
                    ["2-s"] = "H",
                    ["3-s"] = "t",
                    ["1-d"] = "va",
                    ["2-d"] = "tam",
                    ["3-d"] = "tAm",
                    ["1-p"] = "ma",
                    ["2-p"] = "ta",
                    ["3-p"] = "an"
                },
                ["them"] = {
                    ["1-s"] = "am",
                    ["2-s"] = "aH",
                    ["3-s"] = "at",
                    ["1-d"] = "Ava",
                    ["2-d"] = "atam",
                    ["3-d"] = "atAm",
                    ["1-p"] = "Ama",
                    ["2-p"] = "ata",
                    ["3-p"] = "an"
                }
            },
            -- ADD siṣ AORIST
            ["mv"] = {
                ["iṣ"] = {
                    ["1-s"] = "si",
                    ["2-s"] = "sTAH",
                    ["3-s"] = "sta",
                    ["1-d"] = "svahi",
                    ["2-d"] = "sATAm",
                    ["3-d"] = "sAtAm",
                    ["1-p"] = "smahi",
                    ["2-p"] = "iDvam",
                    ["3-p"] = "sata"
                },
                ["ṣ"] = {
                    ["1-s"] = "si",
                    ["2-s"] = "sTAH",
                    ["3-s"] = "sta",
                    ["1-d"] = "svahi",
                    ["2-d"] = "sATAm",
                    ["3-d"] = "sAtAm",
                    ["1-p"] = "smahi",
                    ["2-p"] = "iDvam",
                    ["3-p"] = "sata"
                },
                ["t"] = {
                    ["1-s"] = "si",
                    ["2-s"] = "TAH",
                    ["3-s"] = "ta",
                    ["1-d"] = "svahi",
                    ["2-d"] = "sATAm",
                    ["3-d"] = "sAtAm",
                    ["1-p"] = "smahi",
                    ["2-p"] = "iDvam",
                    ["3-p"] = "sata"
                },
                ["kṣ"] = {
                    ["1-s"] = "i",
                    ["2-s"] = "aTAH",
                    ["3-s"] = "ata",
                    ["1-d"] = "Avahi",
                    ["2-d"] = "ATAm",
                    ["3-d"] = "AtAm",
                    ["1-p"] = "Amahi",
                    ["2-p"] = "aDvam",
                    ["3-p"] = "anta"
                }
            }
            -- ADD PASSIVE ENDINGS HERE
        }
    },
    ["bene"] = {
        ["optat"] = {
            ["av"] = {
                ["1-s"] = "yAsam",
                ["2-s"] = "yAH",
                ["3-s"] = "yAt",
                ["1-d"] = "yAsva",
                ["2-d"] = "yAstam",
                ["3-d"] = "yAstAm",
                ["1-p"] = "yAsma",
                ["2-p"] = "yAsta",
                ["3-p"] = "yAsuH"
            },
            ["mv"] = {
                ["1-s"] = "sIya",
                ["2-s"] = "sIzWAH",
                ["3-s"] = "sIzwa",
                ["1-d"] = "sIvahi",
                ["2-d"] = "sIyAsTAm",
                ["3-d"] = "sIyAstAm",
                ["1-p"] = "sImahi",
                ["2-p"] = "sIDvam",
                ["3-p"] = "sIran"
            }
        }
    },
    ["perf"] = {
        ["indic"] = {
            ["av"] = {
                ["1-s"] = "a",
                ["2-s"] = "iTa",
                ["3-s"] = "a",
                ["1-d"] = "iva",
                ["2-d"] = "aTuH",
                ["3-d"] = "atuH",
                ["1-p"] = "ima",
                ["2-p"] = "a",
                ["3-p"] = "uH"
            },
            ["mv"] = {
                ["1-s"] = "e",
                ["2-s"] = "ize",
                ["3-s"] = "e",
                ["1-d"] = "ivahe",
                ["2-d"] = "ATe",
                ["3-d"] = "Ate",
                ["1-p"] = "imAhe",
                ["2-p"] = "iDve",
                ["3-p"] = "ire"
            }
        },
        ["part"] = {
            ["av"] = "vAMs",
            ["mv"] = "Ana"
        }
    }
}

local athematic_tense_moods = {
    ["pres"] = {
        ["indic"] = {
            ["av"] = {
                ["1-s"] = "mi",
                ["2-s"] = "si",
                ["3-s"] = "ti",
                ["1-d"] = "vaH",
                ["2-d"] = "TaH",
                ["3-d"] = "taH",
                ["1-p"] = "maH",
                ["2-p"] = "Ta",
                ["3-p"] = "anti"
            },
            ["mv"] = {
                ["1-s"] = "e",
                ["2-s"] = "se",
                ["3-s"] = "te",
                ["1-d"] = "vahe",
                ["2-d"] = "ATe",
                ["3-d"] = "Ate",
                ["1-p"] = "mahe",
                ["2-p"] = "Dve",
                ["3-p"] = "Ate"
            },
            ["pv"] = {
                ["1-s"] = "ye",
                ["2-s"] = "yase",
                ["3-s"] = "yate",
                ["1-d"] = "yAvahe",
                ["2-d"] = "yeTe",
                ["3-d"] = "yete",
                ["1-p"] = "yAmahe",
                ["2-p"] = "yaDve",
                ["3-p"] = "yante"
            }
        },
        ["imper"] = {
            ["av"] = {
                ["1-s"] = "Ani",
                ["2-s"] = {"Di", "tAt"},
                ["3-s"] = {"tu", "tAt"},
                ["1-d"] = "Ava",
                ["2-d"] = "tam",
                ["3-d"] = "tAm",
                ["1-p"] = "Ama",
                ["2-p"] = "ta",
                ["3-p"] = "antu"
            },
            ["mv"] = {
                ["1-s"] = "E",
                ["2-s"] = "sva",
                ["3-s"] = "tAm",
                ["1-d"] = "AvahE",
                ["2-d"] = "ATAm",
                ["3-d"] = "AtAm",
                ["1-p"] = "AmahE",
                ["2-p"] = "Dvam",
                ["3-p"] = "atAm"
            },
            ["pv"] = {
                ["1-s"] = "yE",
                ["2-s"] = "yasva",
                ["3-s"] = "yatAm",
                ["1-d"] = "yAvahE",
                ["2-d"] = "yeTAm",
                ["3-d"] = "yetAm",
                ["1-p"] = "yAmahE",
                ["2-p"] = "yaDvam",
                ["3-p"] = "yantam"
            }
        },
        ["optat"] = {
            ["av"] = {
                ["1-s"] = "yAm",
                ["2-s"] = "yAH",
                ["3-s"] = "yAt",
                ["1-d"] = "yAva",
                ["2-d"] = "yAtam",
                ["3-d"] = "yAtAm",
                ["1-p"] = "yAma",
                ["2-p"] = "yAta",
                ["3-p"] = "yuH"
            },
            ["mv"] = {
                ["1-s"] = "Iya",
                ["2-s"] = "ITAH",
                ["3-s"] = "Ita",
                ["1-d"] = "Ivahi",
                ["2-d"] = "IyATAm",
                ["3-d"] = "IyAtAm",
                ["1-p"] = "Imahi",
                ["2-p"] = "IDvam",
                ["3-p"] = "Iran"
            },
            ["pv"] = {
                ["1-s"] = "yeya",
                ["2-s"] = "yeTAH",
                ["3-s"] = "yeta",
                ["1-d"] = "yevahi",
                ["2-d"] = "yeyATAm",
                ["3-d"] = "yeyAtAm",
                ["1-p"] = "yemahi",
                ["2-p"] = "yeDvam",
                ["3-p"] = "yeran"
            }
        },
        ["part"] = {
            ["av"] = {"ant", "at"},
            ["mv"] = "Ana",
            ["pv"] = "yamAna"
        }
    },
    ["impf"] = {
        ["indic"] = {
            ["av"] = {
                ["1-s"] = "am",
                ["2-s"] = "H",
                ["3-s"] = "t",
                ["1-d"] = "va",
                ["2-d"] = "tam",
                ["3-d"] = "tAm",
                ["1-p"] = "ma",
                ["2-p"] = "ta",
                ["3-p"] = "an"
            },
            ["mv"] = {
                ["1-s"] = "i",
                ["2-s"] = "TAH",
                ["3-s"] = "ta",
                ["1-d"] = "vahi",
                ["2-d"] = "ATAm",
                ["3-d"] = "AtAm",
                ["1-p"] = "mahi",
                ["2-p"] = "Dvam",
                ["3-p"] = "atAm"
            },
            ["pv"] = {
                ["1-s"] = "ye",
                ["2-s"] = "yaTAH",
                ["3-s"] = "yata",
                ["1-d"] = "yAvahi",
                ["2-d"] = "yeTAm",
                ["3-d"] = "yetAm",
                ["1-p"] = "yAmahi",
                ["2-p"] = "yaDvam",
                ["3-p"] = "yanta"
            }
        }
    }
}

local function gerundive_sanitize(e)
    return function(stem, auto_sandhi)
        if zsub(stem, -1) == "i" then
            stem = ssub(stem, 1, -2)
        end
        if auto_sandhi then
            return sa_utils.internal_sandhi(
                {
                    stem = stem,
                    ending = e,
                    non_final = true
                }
            )
        else
            return stem .. e
        end
    end
end

local nonf_forms = {
    inf = "tum",
    gerund = "tvA",
    gerundive_mn = {
        gerundive_sanitize("ya"),
        "tavya",
        gerundive_sanitize("anIya")
    },
    gerundive_f = {gerundive_sanitize("yA"), "tavyA", gerundive_sanitize("anIyA")},
    part_mn = "ta",
    part_f = "tA"
}

export.tenses = {
    nonf = {
        name = "Non-Finite Forms",
        moods = {
            {"inf", "Infinitive"},
            {"gerund", "Gerund"},
            {"gerundive_mn", "Masculine/Neuter Gerundive"},
            {"gerundive_f", "Feminine Gerundive"},
            {"part_mn", "Masculine/Neuter Past Passive Participle"},
            {"part_f", "Feminine Past Passive Participle"}
        },
        get_stem = function(infinitive, part, mood, is_thematic)
            if (mood == "inf" or mood == "gerundive_mn" or mood == "gerundive_f") or part == nil then
                return ssub(infinitive, 1, -4) -- remove -tum
            end
            return ssub(part, 1, -3) -- remove -ta
        end,
        get_endings = function(infinitive, part, mood, is_thematic)
            return nonf_forms[mood]
        end
    },
    pres = {
        name = "Present",
        moods = {
            {"indic", "Indicative"},
            {"imper", "Imperative"},
            {"optat", "Optative/Potential"},
            {"part", "Participles"}
        },
        voices = {"av", "mv", "pv"},
        has_part = true,
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
        	if mood == "part" and voice ==  "pv" and passive_lemma ~= nil then
        		return ssub(passive_lemma, 1, -5);
        	end
            if mood == "part" and weak_lemma ~= nil then
                return ssub(weak_lemma, 1, -5) -- remove -anti
            elseif mood == "part" then
                return ssub(strong_lemma, 1, -4) -- remove -ati
            end

            if (voice == "pv" and passive_lemma ~= nil) then
                return ssub(passive_lemma, 1, -5) -- remove -yate
            elseif is_thematic then
                return ssub(strong_lemma, 1, -4) -- remove -ati
            elseif
                not is_thematic and
                    ((mood == "indic" and voice == "av" and match(ending, "s")) or
                        (mood == "imper" and (voice == "av" or voice == "mv") and
                            (match(ending, "1"))))
             then
                return ssub(strong_lemma, 1, -3) -- remove -ti
            elseif not is_thematic then
                return ssub(weak_lemma, 1, -5) -- remove -anti
            end
            error("stem not recognized")
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            if mood == "part" then
            	if is_thematic ~= true then
            		return athematic_tense_moods["pres"][mood][voice]
            	end
                return thematic_tense_moods["pres"][mood][voice]
            end
            local endings = thematic_tense_moods["pres"][mood][voice][ending]
            if is_thematic ~= true then
                endings = athematic_tense_moods["pres"][mood][voice][ending]
            end
            return endings
        end
    },
    impf = {
        name = "Imperfect",
        moods = {
            {"indic", "Indicative"}
        },
        voices = {"av", "mv", "pv"},
        has_part = false,
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            if (voice == "pv" and passive_lemma ~= nil) then
                return ssub(passive_lemma, 1, -5) -- remove -yata
            elseif is_thematic then
                return ssub(strong_lemma, 1, -3) -- remove -at
            elseif
                not is_thematic and
                    ((mood == "indic" and voice == "av" and match(ending, "s")) or
                        (mood == "imper" and voice == "av" and
                            (ending == "1-s" or ending == "3-s" or ending == "1-d" or ending == "1-p")))
             then
                return ssub(strong_lemma, 1, -2) -- remove -t
            elseif not is_thematic then
                return ssub(weak_lemma, 1, -3) -- remove -an
            end
            error("stem not recognized")
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            local endings = thematic_tense_moods["impf"][mood][voice][ending]
            if is_thematic ~= true then
                endings = athematic_tense_moods["impf"][mood][voice][ending]
            end
            return endings
        end
    },
    fut = {
        name = "Future",
        moods = {
            {"simple", "Simple"},
            {"periph", "Peripherastic"},
            {"part", "Participles"}
        },
        voices = {"av", "mv"},
        has_part = true,
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
        	if mood == "periph" and weak_lemma ~= nil then
        		return ssub(weak_lemma, 1, -3) -- remove -tA
        	end
            return ssub(strong_lemma, 1, -6) -- remove -zyati or -syati
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            if mood == "part" then
                return thematic_tense_moods["fut"][mood][voice]
            end
            if voice == "mv" and mood == "periph" then
                return nil
            end
            return thematic_tense_moods["fut"][mood][voice][ending]
        end
    },
    cond = {
        name = "Conditional",
        moods = {
            {"indic", "Indicative"}
        },
        voices = {"av", "mv"},
        has_part = false,
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            return ssub(strong_lemma, 1, -5) -- remove -zyat
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            return thematic_tense_moods["cond"][mood][voice][ending]
        end
    },
    aor = {
        name = "Aorist",
        moods = {
            {"indic", "Indicative"}
        },
        voices = {"av", "mv"},
        has_part = false, -- change this to true eventually, but the aorist participle is exceedingly uncommon
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            local stem = strong_lemma
            if voice == "mv" and passive_lemma then
                stem = passive_lemma
            end
            if zsub(stem, -2) == "It" and (zsub(stem, -3) ~= "zIt" and zsub(stem, -3) ~= "sIt") then
                -- seṭ root
                local s = ssub(stem, 1, -3)
                if zsub(s, -1) ~= "i" then
                    s = s .. "i"
                end
                return s
            elseif zsub(stem, -4) == "izwa" then
                -- seṭ root (middle)
                return ssub(stem, 1, -4)
            elseif (zsub(stem, -3) == "zwa" or zsub(stem, -3) == "sta") then
                -- aniṭ root (middle)
                return ssub(stem, 1, -4)
            elseif zsub(stem, -2) == "It" then
                -- aniṭ root
                return ssub(stem, 1, -4)
            elseif zsub(stem, -2) == "at" then
                -- thematic aorist (i.e. thematic imperfect endings)
                return ssub(stem, 1, -3) -- remove -at
            elseif zsub(stem, -1) == "t" then
                -- athematic aorist (i.e. athematic imperfect endings)
                return ssub(stem, 1, -2) -- remove -t
            elseif zsub(stem, -3) == "ata" then
                -- kṣ aorist (middle, the active is already recognized by thematic aorist)
                return ssub(stem, 1, -4)
            elseif zsub(stem, -2) == "ta" then
                -- modified aniṭ root (middle)
                return ssub(stem, 1, -3)
            end
            error("can't handle this type of aorist")
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            local stem = strong_lemma
            local endings = thematic_tense_moods["aor"][mood][voice]
            if voice == "mv" and passive_lemma then
                stem = passive_lemma
            end
            if zsub(stem, -2) == "It" and (zsub(stem, -3) ~= "zIt" and zsub(stem, -3) ~= "sIt") then
                -- seṭ root
                return endings["iṣ"][ending]
            elseif zsub(stem, -4) == "izwa" then
                -- seṭ root (middle)
                return endings["iṣ"][ending]
            elseif (zsub(stem, -3) == "zwa" or zsub(stem, -3) == "sta") then
                -- aniṭ root (middle)
                return endings["ṣ"][ending]
            elseif zsub(stem, -2) == "It" then
                -- aniṭ root
                return endings["ṣ"][ending]
            elseif zsub(stem, -2) == "at" then
                -- thematic aorist (i.e. thematic imperfect endings)
                if (voice == "mv") then error("need middle stem for aorist") end
                return endings["them"][ending]
            elseif zsub(stem, -1) == "t" then
                -- athematic aorist (i.e. athematic imperfect endings)
                if (voice == "mv") then error("need middle stem for aorist") end
                return endings["root"][ending]
            elseif zsub(stem, -3) == "ata" then
                -- kṣ aorist (middle, the active is already recognized by thematic aorist)
                return endings["kṣ"][ending]
            elseif zsub(stem, -2) == "ta" then
                -- modified aniṭ root (middle)
                return endings["t"][ending]
            end
            error("can't handle this type of aorist")
        end
    },
    bene = {
        name = "Benedictive/Precative",
        moods = {
            {"optat", "Optative"}
        },
        voices = {"av", "mv"},
        has_part = false,
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            local stem = strong_lemma
            if voice == "av" or passive_lemma == nil then
                local s = ssub(strong_lemma, 1, -4) -- remove -yAt
                if voice == "mv" then
                    if zsub(s, -1) ~= "i" then
                        s = s .. "i"
                    end
                end
                return s
            elseif passive_lemma ~= nil then
                return ssub(passive_lemma, 1, -6) -- remove -sIzwa
            end
            error("can't handle this type of benedictive")
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            return thematic_tense_moods["bene"][mood][voice][ending]
        end
    },
    perf = {
        name = "Perfect",
        moods = {
            {"indic", "Indicative"},
            {"part", "Participles"}
        },
        voices = {"av", "mv"},
        has_part = true,
        get_stem = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            if (voice == "av" and mood == "indic" and match(ending, "s")) or weak_lemma == nil then
                return ssub(strong_lemma, 1, -2) -- remove -a
            elseif weak_lemma ~= nil then
                return ssub(weak_lemma, 1, -3)
            end
            error("can't handle this type of perfect")
        end,
        get_endings = function(strong_lemma, weak_lemma, passive_lemma, mood, voice, ending, is_thematic)
            if mood == "part" then
                return thematic_tense_moods["perf"][mood][voice]
            end
            return thematic_tense_moods["perf"][mood][voice][ending]
        end
    }
}

return export