Module:User:Dragonoid76/sa-verb/data

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

local conj_data = {}

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

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

-- Returns { form, stem } if the stem is explicity provided in the form (i.e. form = "rinakti " or form = "rincanti ") 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

-- Splits "stem1,stem2" into { stem1, stem2 } local function split_stems(form) return split(form, ",") end

-- Gets stems for COMPLEX_FORM given a pattern in MATCH_RE local function get_stem(complex_form, match_re) local s = split_xs(complex_form) if s[2] ~= nil then return s[2] end return match(s[1], match_re) end

local function apply_ending(args, data, tag, stem, es, is_part) if type(es) == "string" then es = {es} end local forms = data.forms[tag] or {} local i = #forms + 1 for _, e in ipairs(es) do       local note if type(e) == "table" then note = e.note e = e[1] end

local set_stem = stem if args.set == true and match(stem, sa_utils.consonant .. "$") and match(e, "^" .. sa_utils.consonant) then set_stem = sa_utils.internal_sandhi({               stem = stem,                ending = "i",                non_final = true,                mono = args.mono            }) end

if args.auto_sandhi == true then forms[i] = sa_utils.internal_sandhi({               stem = set_stem,                ending = e,                ignore_s_allophones = true,                non_final = is_part,                mono = args.mono            }) else forms[i] = set_stem .. e       end

if note then forms["note" .. i] = note end i = i + 1 end data.forms[tag] = forms end

local function make_forms(args, data, stem, forms) for mood, mood_forms in pairs(forms) do   	if args.tense == "nonf" then local tag = mood apply_ending(args, data, tag, stem, mood_forms, false) else for voice, voice_forms in pairs(mood_forms) do	           if mood == "part" then local tag = mood .. "_" .. voice apply_ending(args, data, tag, stem, voice_forms, true) else for person_number, es in pairs(voice_forms) do local tag = mood .. "_" .. voice .. "_" .. person_number apply_ending(args, data, tag, stem, es, false) end end end end end end

local function validate_strong_stem(strong_stem, strong_lemma) if strong_stem == nil then error("could not detect stem from " .. strong_lemma .. "; set args.o to fill in values manually") end end

-- Returns { stems, accents } local function get_stems_from_lemmas(lemma, match_pattern, oxy_match_pattern) local strong_lemmas = split_stems(lemma) local strong_stems = {} local oxys = nil if oxy_match_pattern ~= nil then oxys = {} end for i, strong_lemma in ipairs(strong_lemmas) do       local prov = split_xs(strong_lemma)[1] if oxy_match_pattern ~= nil then oxys[i] = match(prov, oxy_match_pattern) end strong_stems[i] = get_stem(strong_lemma, match_pattern) validate_strong_stem(strong_stems[i], strong_lemma) end return { strong_stems, oxys } end

conj_data["pres"] = {} setmetatable(conj_data["pres"], {   __call = function (self, args, data)        local is_thematic = args.weak_lemma == nil

local strong_stem if is_thematic then local strong_lemma = args.strong_lemma local prov = split_xs(strong_lemma)[1] local oxy = match(prov, "(" .. sa_utils.accent .. "?)ti$") and "/" or "" strong_stem = get_stem(strong_lemma, "(.+)a" .. sa_utils.accent .. "?ti$") validate_strong_stem(strong_stem, strong_lemma)

make_forms(args, data, strong_stem, {               ["indic"] = {                    ["av"] = {                        ["1_s"] = "A" .. oxy .. "mi",                        ["2_s"] = "a" .. oxy .. "si",                        ["3_s"] = "a" .. oxy .. "ti",                        ["1_d"] = "A" .. oxy .. "vas",                        ["2_d"] = "a" .. oxy .. "Tas",                        ["3_d"] = "a" .. oxy .. "tas",                        ["1_p"] = "A" .. oxy .. "mas",                        ["2_p"] = "a" .. oxy .. "Ta",                        ["3_p"] = "a" .. oxy .. "nti"                    },                    ["mv"] = {                        ["1_s"] = "e" .. oxy .. "",                        ["2_s"] = "a" .. oxy .. "se",                        ["3_s"] = "a" .. oxy .. "te",                        ["1_d"] = "A" .. oxy .. "vahe",                        ["2_d"] = "e" .. oxy .. "Te", ["3_d"] = "e" .. oxy .. "te", ["1_p"] = "A" .. oxy .. "mahe", ["2_p"] = "a" .. oxy .. "Dve", ["3_p"] = "a" .. oxy .. "nte" }               },                ["imper"] = { ["av"] = { ["1_s"] = "A" .. oxy .. "ni", ["2_s"] = {"a" .. oxy, "a" .. oxy .. "tAt"}, ["3_s"] = {"a" .. oxy .. "tu", "a" .. oxy .. "tAt"}, ["1_d"] = "A" .. oxy .. "va", ["2_d"] = "a" .. oxy .. "tam", ["3_d"] = "a" .. oxy .. "tAm", ["1_p"] = "A" .. oxy .. "ma", ["2_p"] = "a" .. oxy .. "ta", ["3_p"] = "a" .. oxy .. "ntu" },                   ["mv"] = { ["1_s"] = "E" .. oxy .. "",                       ["2_s"] = "a" .. oxy .. "sva", ["3_s"] = "a" .. oxy .. "tAm", ["1_d"] = "A" .. oxy .. "vahE", ["2_d"] = "e" .. oxy .. "TAm", ["3_d"] = "e" .. oxy .. "tAm", ["1_p"] = "A" .. oxy .. "mahE", ["2_p"] = "a" .. oxy .. "Dvam", ["3_p"] = "a" .. oxy .. "ntam" },               },                ["optat"] = { ["av"] = { ["1_s"] = "e" .. oxy .. "yam", ["2_s"] = "e" .. oxy .. "s", ["3_s"] = "e" .. oxy .. "t", ["1_d"] = "e" .. oxy .. "va", ["2_d"] = "e" .. oxy .. "tam", ["3_d"] = "e" .. oxy .. "tAm", ["1_p"] = "e" .. oxy .. "mas", ["2_p"] = "e" .. oxy .. "ta", ["3_p"] = "e" .. oxy .. "yus" },                   ["mv"] = { ["1_s"] = "e" .. oxy .. "ya", ["2_s"] = "e" .. oxy .. "TAs", ["3_s"] = "e" .. oxy .. "ta", ["1_d"] = "e" .. oxy .. "vahi", ["2_d"] = "e" .. oxy .. "yATAm", ["3_d"] = "e" .. oxy .. "yAtAm", ["1_p"] = "e" .. oxy .. "mahi", ["2_p"] = "e" .. oxy .. "Dvam", ["3_p"] = "e" .. oxy .. "rant" },               },                ["part"] = { ["av"] = "a" .. oxy .. "t", ["mv"] = "a" .. oxy .. "mAna" }           })        else            local strong_lemma = args.strong_lemma            strong_stem = get_stem(strong_lemma, "(.+)ti$")            validate_strong_stem(strong_stem, strong_lemma)            make_forms(args, data, strong_stem, { ["indic"] = { ["av"] = { ["1_s"] = "mi", ["2_s"] = "si", ["3_s"] = "ti", },               },                ["imper"] = { ["av"] = { ["1_s"] = "Ani", ["1_d"] = "Ava", ["1_p"] = "Ama", },                   ["mv"] = { ["1_s"] = "E", ["1_d"] = "AvahE", ["1_p"] = "AmahE", },               },            })

local weak_lemma = args.weak_lemma local prov = split_xs(weak_lemma)[1] local oxy = match(prov, sa_utils.accent) and "/" or "" local weak_stem = get_stem(weak_lemma, "(.+)a" .. sa_utils.accent .. "?nti$") validate_strong_stem(weak_stem, weak_lemma) make_forms(args, data, weak_stem, {               ["indic"] = {                    ["av"] = {                        ["1_d"] = "va" .. oxy .. "s",                        ["2_d"] = "Ta" .. oxy .. "s",                        ["3_d"] = "ta" .. oxy .. "s",                        ["1_p"] = "ma" .. oxy .. "s",                        ["2_p"] = "Ta" .. oxy,                        ["3_p"] = "a" .. oxy .. "nti"                    },                    ["mv"] = {                        ["1_s"] = "e" .. oxy,                        ["2_s"] = "se" .. oxy,                        ["3_s"] = "te" .. oxy,                        ["1_d"] = "va" .. oxy .. "he",                        ["2_d"] = "A" .. oxy .. "Te",                        ["3_d"] = "A" .. oxy .. "te",                        ["1_p"] = "ma" .. oxy .. "he",                        ["2_p"] = "Dve" .. oxy,                        ["3_p"] = "a" .. oxy .. "te" }               },                ["imper"] = { ["av"] = { ["2_s"] = {"Di" .. oxy, "tA" .. oxy .. "t"}, ["3_s"] = {"tu" .. oxy, "tA" .. oxy .. "t"}, ["2_d"] = "ta" .. oxy .. "m", ["3_d"] = "tA" .. oxy .. "m", ["2_p"] = "ta" .. oxy .. "",                       ["3_p"] = "a" .. oxy .. "ntu" },                   ["mv"] = { ["2_s"] = "sva" .. oxy, ["3_s"] = "tA" .. oxy .. "m", ["2_d"] = "A" .. oxy .. "TAm", ["3_d"] = "A" .. oxy .. "tAm", ["2_p"] = "Dva" .. oxy .. "m", ["3_p"] = "a" .. oxy .. "tAm" }               },                ["optat"] = { ["av"] = { ["1_s"] = "yA" .. oxy .. "m", ["2_s"] = "yA" .. oxy .. "s", ["3_s"] = "yA" .. oxy .. "t", ["1_d"] = "yA" .. oxy .. "va", ["2_d"] = "yA" .. oxy .. "tam", ["3_d"] = "yA" .. oxy .. "tAm", ["1_p"] = "yA" .. oxy .. "ma", ["2_p"] = "yA" .. oxy .. "ta", ["3_p"] = "yu" .. oxy .. "s" },                   ["mv"] = { ["1_s"] = "Iya" .. oxy, ["2_s"] = "ITA" .. oxy .. "s", ["3_s"] = "Ita" .. oxy .. "",                       ["1_d"] = "Iva" .. oxy .. "hi", ["2_d"] = "IyA" .. oxy .. "TAm", ["3_d"] = "IyA" .. oxy .. "tAm", ["1_p"] = "Ima" .. oxy .. "hi", ["2_p"] = "IDva" .. oxy .. "m", ["3_p"] = "Ira" .. oxy .. "n" }               },                ["part"] = { ["av"] = "a" .. oxy .. "t", ["mv"] = "A" .. oxy .. "na", }           })        end

local oxy, passive_stem if args.passive_lemma then local passive_lemma = args.passive_lemma local prov = split_xs(passive_lemma)[1] oxy = match(prov, "ya(" .. sa_utils.accent .. "?)te$") and "/" or "/" passive_stem = get_stem(passive_lemma, "(.+)ya" .. sa_utils.accent .. "?te$") validate_strong_stem(passive_stem, passive_lemma) else passive_stem = gsub(strong_stem, sa_utils.accent, "") oxy = match(strong_stem, sa_utils.accent) and "/" or "/" end

make_forms(args, data, passive_stem, {           ["indic"] = {                ["pv"] = {                    ["1_s"] = "ye" .. oxy,                    ["2_s"] = "ya" .. oxy .. "se",                    ["3_s"] = "ya" .. oxy .. "te",                    ["1_d"] = "yA" .. oxy .. "vahe",                    ["2_d"] = "ye" .. oxy .. "Te",                    ["3_d"] = "ye" .. oxy .. "te",                    ["1_p"] = "yA" .. oxy .. "mahe",                    ["2_p"] = "ya" .. oxy .. "Dve",                    ["3_p"] = "ya" .. oxy .. "nte"                }            },            ["imper"] = {                ["pv"] = {                    ["1_s"] = "yE" .. oxy,                    ["2_s"] = "ya" .. oxy .. "sva",                    ["3_s"] = "ya" .. oxy .. "tAm",                    ["1_d"] = "yA" .. oxy .. "vahE",                    ["2_d"] = "ye" .. oxy .. "TAm",                    ["3_d"] = "ye" .. oxy .. "tAm", ["1_p"] = "yA" .. oxy .. "mahE", ["2_p"] = "ya" .. oxy .. "Dvam", ["3_p"] = "ya" .. oxy .. "ntam" }           },            ["optat"] = { ["pv"] = { ["1_s"] = "ye" .. oxy .. "ya", ["2_s"] = "ye" .. oxy .. "TAs", ["3_s"] = "ye" .. oxy .. "ta", ["1_d"] = "ye" .. oxy .. "vahi", ["2_d"] = "ye" .. oxy .. "yATAm", ["3_d"] = "ye" .. oxy .. "yAtAm", ["1_p"] = "ye" .. oxy .. "mahi", ["2_p"] = "ye" .. oxy .. "Dvam", ["3_p"] = "ye" .. oxy .. "rant" }           },            ["part"] = { ["pv"] = "ya" .. oxy .. "mAna" }       })    end })

conj_data["impf"] = {} setmetatable(conj_data["impf"], {   __call = function (self, args, data)        local is_thematic = args.weak_lemma == nil

local strong_stem if is_thematic then local strong_lemma = args.strong_lemma strong_stem = get_stem(strong_lemma, "(.+)at$") validate_strong_stem(strong_stem, strong_lemma)

make_forms(args, data, strong_stem, {               ["indic"] = {                    ["av"] = {                        ["1_s"] = "am",                        ["2_s"] = "as",                        ["3_s"] = "at",                        ["1_d"] = "Ava",                        ["2_d"] = "atam",                        ["3_d"] = "atAm",                        ["1_p"] = "Ama",                        ["2_p"] = "ata",                        ["3_p"] = "ant"                    },                    ["mv"] = {                        ["1_s"] = "e",                        ["2_s"] = "aTAs",                        ["3_s"] = "ata",                        ["1_d"] = "Avahi",                        ["2_d"] = "eTAm",                        ["3_d"] = "etAm",                        ["1_p"] = "Amahi",                        ["2_p"] = "aDvam",                        ["3_p"] = "anta"                    }, }           })        else            local strong_lemma = args.strong_lemma            strong_stem = get_stem(strong_lemma, "(.+)t$")            validate_strong_stem(strong_stem, strong_lemma)            make_forms(args, data, strong_stem, { ["indic"] = { ["av"] = { ["1_s"] = "am", ["2_s"] = "s", ["3_s"] = "t", },               },            })

local weak_lemma = args.weak_lemma local weak_stem = get_stem(weak_lemma, "(.+)an$") make_forms(args, data, weak_stem, {               ["indic"] = {                    ["av"] = {                        ["1_d"] = "va",                        ["2_d"] = "tam",                        ["3_d"] = "tAm",                        ["1_p"] = "ma",                        ["2_p"] = "ta",                        ["3_p"] = "ant"                    },                    ["mv"] = {                        ["1_s"] = "i",                        ["2_s"] = "TAs",                        ["3_s"] = "ta",                        ["1_d"] = "vahi",                        ["2_d"] = "ATAm",                        ["3_d"] = "AtAm",                        ["1_p"] = "mahi",                        ["2_p"] = "Dvam",                        ["3_p"] = "atAm"                    },                }            }) end

local passive_stem if args.passive_lemma then local passive_lemma = args.passive_lemma passive_stem = get_stem(passive_lemma, "(.+)yata$") validate_strong_stem(passive_stem, passive_lemma) else passive_stem = strong_stem end

make_forms(args, data, passive_stem, {           ["indic"] = {                ["pv"] = {                    ["1_s"] = "ye",                    ["2_s"] = "yaTAs",                    ["3_s"] = "yata",                    ["1_d"] = "yAvahi",                    ["2_d"] = "yeTAm",                    ["3_d"] = "yetAm",                    ["1_p"] = "yAmahi",                    ["2_p"] = "yaDvam",                    ["3_p"] = "yanta"                }            },        }) end })

conj_data["fut"] = {} setmetatable(conj_data["fut"], {   __call = function (self, args, data)        local make_strong_forms = function (oxy)            return {                ["simple"] = {                    ["av"] = {                        ["1_s"] = "syA" .. oxy .. "mi",                        ["2_s"] = "sya" .. oxy .. "si",                        ["3_s"] = "sya" .. oxy .. "ti",                        ["1_d"] = "syA" .. oxy .. "vas",                        ["2_d"] = "sya" .. oxy .. "Tas",                        ["3_d"] = "sya" .. oxy .. "tas",                        ["1_p"] = "syA" .. oxy .. "mas",                        ["2_p"] = "sya" .. oxy .. "Ta",                        ["3_p"] = "sya" .. oxy .. "nti"                    },                    ["mv"] = {                        ["1_s"] = "sye" .. oxy,                        ["2_s"] = "sya" .. oxy .. "se",                        ["3_s"] = "sya" .. oxy .. "te", ["1_d"] = "syA" .. oxy .. "vahe", ["2_d"] = "sye" .. oxy .. "Te", ["3_d"] = "sye" .. oxy .. "te", ["1_p"] = "syA" .. oxy .. "mahe", ["2_p"] = "sya" .. oxy .. "Dve", ["3_p"] = "sya" .. oxy .. "nte" }               },                ["part"] = { ["av"] = "sya" .. oxy .. "t", ["mv"] = "syA" .. oxy .. "na" }           }        end

local make_perph_forms = function (oxy) return { ["periph"] = { ["av"] = { ["1_s"] = "tA" .. oxy .. "smi", ["2_s"] = "tA" .. oxy .. "si", ["3_s"] = "tA" .. oxy, ["1_d"] = "tA" .. oxy .. "svas", ["2_d"] = "tA" .. oxy .. "sTas", ["3_d"] = "tA" .. oxy .. "rO", ["1_p"] = "tA" .. oxy .. "smas", ["2_p"] = "tA" .. oxy .. "sTa", ["3_p"] = "tA" .. oxy .. "ras" },                   ["mv"] = { ["1_s"] = "tA" .. oxy .. "he", ["2_s"] = "tA" .. oxy .. "se", ["3_s"] = "tA" .. oxy, ["1_d"] = "tA" .. oxy .. "svahe", ["2_d"] = "tA" .. oxy .. "sATe", ["3_d"] = "tA" .. oxy .. "rO", ["1_p"] = "tA" .. oxy .. "smahe", ["2_p"] = "tA" .. oxy .. "Dve", ["3_p"] = "tA" .. oxy .. "ras" }               },            }        end

local strong_stems = get_stems_from_lemmas(			args.strong_lemma, 			"(.+).ya" .. sa_utils.accent .. "?ti$", 			"(" .. sa_utils.accent .. "?)ti$"		) for i, strong_stem in ipairs(strong_stems[1]) do	       make_forms(args, data, strong_stem, make_strong_forms(strong_stems[2][i])) end

local weak_lemma = args.weak_lemma or args.passive_lemma if weak_lemma == nil then for i, strong_stem in ipairs(strong_stems[1]) do           	make_forms(args, data, strong_stem, make_perph_forms(strong_stems[2][i])) end else local weak_stems = get_stems_from_lemmas(       		weak_lemma,        		"(.+)tA" .. sa_utils.accent .. "?$",        		"(" .. sa_utils.accent .. "?)$"       	)        	for i, weak_stem in ipairs(weak_stems[1]) do            	make_forms(args, data, weak_stem, make_perph_forms(weak_stems[2][i])) end end end })

conj_data["cond"] = {} setmetatable(conj_data["cond"], {   __call = function (self, args, data)    	local strong_stems = get_stems_from_lemmas( args.strong_lemma, "(.+).yat$" )       for i, strong_stem in ipairs(strong_stems[1]) do        	make_forms(args, data, strong_stem, { ["indic"] = { ["av"] = { ["1_s"] = "syam", ["2_s"] = "syas", ["3_s"] = "syat", ["1_d"] = "syAva", ["2_d"] = "syatam", ["3_d"] = "syatAm", ["1_p"] = "syAma", ["2_p"] = "syata", ["3_p"] = "syant" },	               ["mv"] = { ["1_s"] = "sye", ["2_s"] = "syaTAs", ["3_s"] = "syata", ["1_d"] = "syAvahi", ["2_d"] = "syeTAm", ["3_d"] = "syetAm", ["1_p"] = "syAmahi", ["2_p"] = "syaDvam", ["3_p"] = "syanta" }	           }         	})        end    end })

conj_data["aor"] = {} setmetatable(conj_data["aor"], {   __call = function (self, args, data)        local strong_is_endings = {            ["indic"] = {                ["av"] = {                    ["1_s"] = "izam",                    ["2_s"] = "Is",                    ["3_s"] = "It",                    ["1_d"] = "izva",                    ["2_d"] = "iztam",                    ["3_d"] = "izwAm",                    ["1_p"] = "izma",                    ["2_p"] = "izwa",                    ["3_p"] = "izus"                },            }        }

local weak_is_endings = { ["indic"] = { ["mv"] = { ["1_s"] = "izi", ["2_s"] = "izWAs", ["3_s"] = "izwa", ["1_d"] = "izvahi", ["2_d"] = "izATAm", ["3_d"] = "izAtAm", ["1_p"] = "izmahi", ["2_p"] = "iQvam", ["3_p"] = "izata" },           }        }

local strong_s_endings = { ["indic"] = { ["av"] = { ["1_s"] = "sam", ["2_s"] = "sIs", ["3_s"] = "sIt", ["1_d"] = "sva", ["2_d"] = "stam", ["3_d"] = "stAm", ["1_p"] = "sma", ["2_p"] = "sta", ["3_p"] = "sus" },           }        }        local strong_ks_endings = { ["indic"] = { ["av"] = { ["1_s"] = "sam", ["2_s"] = "sIs", ["3_s"] = "sIt", ["1_d"] = "sva", ["2_d"] = "tam", ["3_d"] = "tAm", ["1_p"] = "sma", ["2_p"] = "ta", ["3_p"] = "sus" },           }        }

local weak_s_endings = { ["indic"] = { ["mv"] = { ["1_s"] = "si", ["2_s"] = "sTAs", ["3_s"] = "sta", ["1_d"] = "svahi", ["2_d"] = "sATAm", ["3_d"] = "sAtAm", ["1_p"] = "smahi", ["2_p"] = "Dvam", ["3_p"] = "sata" },           }        }        local weak_ks_endings = { ["indic"] = { ["mv"] = { ["1_s"] = "si", ["2_s"] = "TAs", ["3_s"] = "ta", ["1_d"] = "svahi", ["2_d"] = "sATAm", ["3_d"] = "sAtAm", ["1_p"] = "smahi", ["2_p"] = "Dvam", ["3_p"] = "sata" },           }        }

local strong_a_endings = { ["indic"] = { ["av"] = { ["1_s"] = "am", ["2_s"] = "as", ["3_s"] = "at", ["1_d"] = "Ava", ["2_d"] = "atam", ["3_d"] = "atAm", ["1_p"] = "Ama", ["2_p"] = "ata", ["3_p"] = "ant" },           }        }

local weak_a_endings = { ["indic"] = { ["mv"] = { ["1_s"] = "e", ["2_s"] = "aTAs", ["3_s"] = "ata", ["1_d"] = "Avahi", ["2_d"] = "eTAm", ["3_d"] = "etAm", ["1_p"] = "Amahi", ["2_p"] = "aDvam", ["3_p"] = "anta" },           }        }

local strong_root_endings = { ["indic"] = { ["av"] = { ["1_s"] = "am", ["2_s"] = "s", ["3_s"] = "t", ["1_d"] = "va", ["2_d"] = "tam", ["3_d"] = "tAm", ["1_p"] = "ma", ["2_p"] = "ta", ["3_p"] = "ant" }           }        }

local strong_lemmas = split_stems(args.strong_lemma) local weak_lemmas = args.weak_lemma or args.passive_lemma for i, strong_lemma in ipairs(strong_lemmas) do			local prov = split_xs(strong_lemma)[1] if match(prov, "It$") and not (match(prov, "sIt$") or match(prov, "zIt$")) then -- iṣ aorist active table.insert(data.categories, "Sanskrit verbs with iṣ-aorist") local strong_stem = get_stem(strong_lemma, "(.+)It$") make_forms(args, data, strong_stem, strong_is_endings) if not weak_lemmas then make_forms(args, data, strong_stem, weak_is_endings) end elseif match(prov, "kzIt$") then -- kṣ aorist active table.insert(data.categories, "Sanskrit verbs with kṣ-aorist") local strong_stem = get_stem(strong_lemma, "(.+).It$") make_forms(args, data, strong_stem, strong_ks_endings) if not weak_lemmas then make_forms(args, data, strong_stem, weak_ks_endings) end elseif match(prov, "It$") then -- ṣ aorist active table.insert(data.categories, "Sanskrit verbs with ṣ-aorist") local strong_stem = get_stem(strong_lemma, "(.+).It$") make_forms(args, data, strong_stem, strong_s_endings) if not weak_lemmas then make_forms(args, data, strong_stem, weak_s_endings) end elseif match(prov, "at$") then -- a aorist / thematic aorist table.insert(data.categories, "Sanskrit verbs with a-aorist") local strong_stem = get_stem(strong_lemma, "(.+)at$") make_forms(args, data, strong_stem, strong_a_endings) if not weak_lemmas then make_forms(args, data, strong_stem, weak_a_endings) end elseif match(prov, "t$") then -- root aorist table.insert(data.categories, "Sanskrit verbs with root aorist") local strong_stem = get_stem(strong_lemma, "(.+)t$") make_forms(args, data, strong_stem, strong_root_endings) else error("Could not detect aorist type from " .. prov) -- failed to recognize an aorist type end end

if weak_lemmas then weak_lemmas = split_stems(weak_lemmas) for i, weak_lemma in ipairs(weak_lemmas) do	           prov = split_xs(weak_lemma)[1] if match(prov, "izwa$") then table.insert(data.categories, "Sanskrit verbs with iṣ-aorist") local weak_stem = get_stem(weak_lemma, "(.+)izwa$") make_forms(args, data, weak_stem, weak_is_endings) elseif match(prov, "kta$") then table.insert(data.categories, "Sanskrit verbs with kṣ-aorist") local weak_stem = get_stem(weak_lemma, "(.+)ta$") make_forms(args, data, weak_stem, weak_ks_endings) elseif match(prov, "sta$") or match(prov, "zwa$") then table.insert(data.categories, "Sanskrit verbs with ṣ-aorist") local weak_stem = get_stem(weak_lemma, "(.+)..a$") make_forms(args, data, weak_stem, weak_s_endings) elseif match(prov, "ata$") then table.insert(data.categories, "Sanskrit verbs with a-aorist") local weak_stem = get_stem(weak_lemma, "(.+)ata$") make_forms(args, data, weak_stem, weak_a_endings) else validate_strong_stem(nil) end end end end })

conj_data["bene"] = {} setmetatable(conj_data["bene"], {   __call = function (self, args, data)        local make_strong_forms = function (oxy)            return {                ["optat"] = {                    ["av"] = {                        ["1_s"] = "yA" .. oxy .. "sam",                        ["2_s"] = "yA" .. oxy .. "s",                        ["3_s"] = "yA" .. oxy .. "t",                        ["1_d"] = "yA" .. oxy .. "sva",                        ["2_d"] = "yA" .. oxy .. "stam",                        ["3_d"] = "yA" .. oxy .. "stAm",                        ["1_p"] = "yA" .. oxy .. "sma",                        ["2_p"] = "yA" .. oxy .. "sta",                        ["3_p"] = "yA" .. oxy .. "sus"                    },                }            }        end

local make_weak_forms = function (oxy) return { ["optat"] = { ["mv"] = { ["1_s"] = "sIya" .. oxy, ["2_s"] = "sIzWA" .. oxy .. "s", ["3_s"] = "sIzwa" .. oxy, ["1_d"] = "sIva" .. oxy .. "hi", ["2_d"] = "sIyA" .. oxy .. "sTAm", ["3_d"] = "sIyA" .. oxy .. "stAm", ["1_p"] = "sIma" .. oxy .. "hi", ["2_p"] = "sIDva" .. oxy .. "m", ["3_p"] = "sIra" .. oxy .. "nt" },               }            }        end local strong_stems = get_stems_from_lemmas(			args.strong_lemma, 			"(.+)yA" .. sa_utils.accent .. "?t$", 			"yA(" .. sa_utils.accent .. "?)t$"		) for i, strong_stem in ipairs(strong_stems[1]) do	       make_forms(args, data, strong_stem, make_strong_forms(strong_stems[2][i])) end

local weak_lemma = args.weak_lemma or args.passive_lemma if weak_lemma == nil then for i, strong_stem in ipairs(strong_stems[1]) do           	make_forms(args, data, strong_stem, make_weak_forms(strong_stems[2][i])) end else local weak_stems = get_stems_from_lemmas(       		weak_lemma,        		"(.+).Izwa" .. sa_utils.accent .. "?$",        		".Izwa(" .. sa_utils.accent .. "?)$"       	)        	for i, weak_stem in ipairs(weak_stems[1]) do            	make_forms(args, data, weak_stem, make_weak_forms(weak_stems[2][i])) end end end })

conj_data["perf"] = {} setmetatable(conj_data["perf"], {   __call = function (self, args, data)        local make_strong_forms = function (oxy)            return {                ["indic"] = {                    ["av"] = {                        ["1_s"] = "a",                        ["2_s"] = "iTa",                        ["3_s"] = "a",                    },                }            }        end

local make_weak_forms = function (oxy) return { ["indic"] = { ["av"] = { ["1_d"] = "iva" .. oxy, ["2_d"] = "a" .. oxy .. "Tus", ["3_d"] = "a" .. oxy .. "tus", ["1_p"] = "ima" .. oxy, ["2_p"] = "a" .. oxy, ["3_p"] = "u" .. oxy .. "s" },                   ["mv"] = { ["1_s"] = "e" .. oxy, ["2_s"] = "ize" .. oxy, ["3_s"] = "e" .. oxy, ["1_d"] = "iva" .. oxy .. "he", ["2_d"] = "A" .. oxy .. "Te", ["3_d"] = "A" .. oxy .. "te", ["1_p"] = "imA" .. oxy .. "he", ["2_p"] = "iDve" .. oxy, ["3_p"] = "ire" .. oxy }               },                ["part"] = { ["av"] = "vA" .. oxy .. "Ms", ["mv"] = "Ana" .. oxy }           }        end local strong_stems = get_stems_from_lemmas(			args.strong_lemma, 			"(.+)a$", 			"(" .. sa_utils.accent .. "?)"		)   	for i, strong_stem in ipairs(strong_stems[1]) do	        make_forms(args, data, strong_stem, make_strong_forms(strong_stems[2][i])) end

local weak_lemma = args.weak_lemma or args.passive_lemma if weak_lemma == nil then for i, strong_stem in ipairs(strong_stems[1]) do           	make_forms(args, data, strong_stem, make_weak_forms(strong_stems[2][i])) end else local weak_stems = get_stems_from_lemmas(       		weak_lemma,        		"(.+)u" .. sa_utils.accent .. "?H$",        		"u(" .. sa_utils.accent .. "?)H$"       	) for i, weak_stem in ipairs(weak_stems[1]) do           	make_forms(args, data, weak_stem, make_weak_forms(weak_stems[2][i])) end end end })

conj_data["nonf"] = {} setmetatable(conj_data["nonf"], {   __call = function (self, args, data)        local make_strong_forms = function (oxy)            return {                ["gerundive_mn"] = { "ya", "tavya" .. oxy, "anI" .. oxy .. "ya" },                ["gerundive_f"] = { "yA", "tavyA" .. oxy, "anI" .. oxy .. "yA" }             }        end

local make_weak_forms = function (oxy) return { ["gerund"] = "tvA" .. oxy, ["part_mn"] = "ta" .. oxy, ["part_f"] = "tA" .. oxy }       end local strong_stems = get_stems_from_lemmas(       	args.strong_lemma,        	"(.+)ya$",        	"(" .. sa_utils.accent .. "?)"       )        for i, strong_stem in ipairs(strong_stems[1]) do        	make_forms(args, data, strong_stem, {	        	["inf"] = "tum"	        }) strong_stem = gsub(strong_stem, sa_utils.accent, "") make_forms(args, data, strong_stem, make_strong_forms(strong_stems[2][i])) local ya_form = #(data.forms["gerundive_mn"]) - 2 -- TODO: This is not a great way of doing this local prov = split_xs(split_stems(args.strong_lemma)[i])[1] data.forms["gerundive_mn"][1] = prov data.forms["gerundive_f"][1] = match(prov, "(.+)a$") .. "A" end

local weak_lemma = args.weak_lemma or args.passive_lemma if weak_lemma == nil then for i, strong_stem in ipairs(strong_stems[1]) do           	make_forms(args, data, gsub(strong_stem, sa_utils.accent, ""), make_weak_forms(strong_stems[2][i])) end else local weak_stems = get_stems_from_lemmas(       		weak_lemma,        		"(.+).a" .. sa_utils.accent .. "?$",        		"a(" .. sa_utils.accent .. "?)$"       	)        	for i, weak_stem in ipairs(weak_stems[1]) do        		make_forms(args, data, weak_stem, make_weak_forms(weak_stems[2][i])) end end end })

return conj_data