This is a private module sandbox of Dragonoid76, for their own experimentation. Items in this module may be added and removed at Dragonoid76's discretion; do not rely on this module's stability.
-- This is a data module for ].
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<rinac>" or form = "rincanti<rinc>")
local function split_xs(form)
if form == nil then
return nil
end
local s = split(form, "<")
if s ~= nil then
local sanitized_s2 = sub(s, 1, -2)
return {s, 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 ~= nil then return s end
return match(s, 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 or {}
local i = #forms + 1
for _, e in ipairs(es) do
local note
if type(e) == "table" then
note = e.note
e = e
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 = sa_utils.internal_sandhi({
stem = set_stem,
ending = e,
ignore_s_allophones = true,
non_final = is_part,
mono = args.mono
})
else
forms = set_stem .. e
end
if note then
forms = note
end
i = i + 1
end
data.forms = 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)
if oxy_match_pattern ~= nil then
oxys = match(prov, oxy_match_pattern)
end
strong_stems = get_stem(strong_lemma, match_pattern)
validate_strong_stem(strong_stems, strong_lemma)
end
return { strong_stems, oxys }
end
conj_data = {}
setmetatable(conj_data, {
__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)
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, {
= {
= {
= "A" .. oxy .. "mi",
= "a" .. oxy .. "si",
= "a" .. oxy .. "ti",
= "A" .. oxy .. "vas",
= "a" .. oxy .. "Tas",
= "a" .. oxy .. "tas",
= "A" .. oxy .. "mas",
= "a" .. oxy .. "Ta",
= "a" .. oxy .. "nti"
},
= {
= "e" .. oxy .. "",
= "a" .. oxy .. "se",
= "a" .. oxy .. "te",
= "A" .. oxy .. "vahe",
= "e" .. oxy .. "Te",
= "e" .. oxy .. "te",
= "A" .. oxy .. "mahe",
= "a" .. oxy .. "Dve",
= "a" .. oxy .. "nte"
}
},
= {
= {
= "A" .. oxy .. "ni",
= {"a" .. oxy, "a" .. oxy .. "tAt"},
= {"a" .. oxy .. "tu", "a" .. oxy .. "tAt"},
= "A" .. oxy .. "va",
= "a" .. oxy .. "tam",
= "a" .. oxy .. "tAm",
= "A" .. oxy .. "ma",
= "a" .. oxy .. "ta",
= "a" .. oxy .. "ntu"
},
= {
= "E" .. oxy .. "",
= "a" .. oxy .. "sva",
= "a" .. oxy .. "tAm",
= "A" .. oxy .. "vahE",
= "e" .. oxy .. "TAm",
= "e" .. oxy .. "tAm",
= "A" .. oxy .. "mahE",
= "a" .. oxy .. "Dvam",
= "a" .. oxy .. "ntam"
},
},
= {
= {
= "e" .. oxy .. "yam",
= "e" .. oxy .. "s",
= "e" .. oxy .. "t",
= "e" .. oxy .. "va",
= "e" .. oxy .. "tam",
= "e" .. oxy .. "tAm",
= "e" .. oxy .. "mas",
= "e" .. oxy .. "ta",
= "e" .. oxy .. "yus"
},
= {
= "e" .. oxy .. "ya",
= "e" .. oxy .. "TAs",
= "e" .. oxy .. "ta",
= "e" .. oxy .. "vahi",
= "e" .. oxy .. "yATAm",
= "e" .. oxy .. "yAtAm",
= "e" .. oxy .. "mahi",
= "e" .. oxy .. "Dvam",
= "e" .. oxy .. "rant"
},
},
= {
= "a" .. oxy .. "t",
= "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, {
= {
= {
= "mi",
= "si",
= "ti",
},
},
= {
= {
= "Ani",
= "Ava",
= "Ama",
},
= {
= "E",
= "AvahE",
= "AmahE",
},
},
})
local weak_lemma = args.weak_lemma
local prov = split_xs(weak_lemma)
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, {
= {
= {
= "va" .. oxy .. "s",
= "Ta" .. oxy .. "s",
= "ta" .. oxy .. "s",
= "ma" .. oxy .. "s",
= "Ta" .. oxy,
= "a" .. oxy .. "nti"
},
= {
= "e" .. oxy,
= "se" .. oxy,
= "te" .. oxy,
= "va" .. oxy .. "he",
= "A" .. oxy .. "Te",
= "A" .. oxy .. "te",
= "ma" .. oxy .. "he",
= "Dve" .. oxy,
= "a" .. oxy .. "te"
}
},
= {
= {
= {"Di" .. oxy, "tA" .. oxy .. "t"},
= {"tu" .. oxy, "tA" .. oxy .. "t"},
= "ta" .. oxy .. "m",
= "tA" .. oxy .. "m",
= "ta" .. oxy .. "",
= "a" .. oxy .. "ntu"
},
= {
= "sva" .. oxy,
= "tA" .. oxy .. "m",
= "A" .. oxy .. "TAm",
= "A" .. oxy .. "tAm",
= "Dva" .. oxy .. "m",
= "a" .. oxy .. "tAm"
}
},
= {
= {
= "yA" .. oxy .. "m",
= "yA" .. oxy .. "s",
= "yA" .. oxy .. "t",
= "yA" .. oxy .. "va",
= "yA" .. oxy .. "tam",
= "yA" .. oxy .. "tAm",
= "yA" .. oxy .. "ma",
= "yA" .. oxy .. "ta",
= "yu" .. oxy .. "s"
},
= {
= "Iya" .. oxy,
= "ITA" .. oxy .. "s",
= "Ita" .. oxy .. "",
= "Iva" .. oxy .. "hi",
= "IyA" .. oxy .. "TAm",
= "IyA" .. oxy .. "tAm",
= "Ima" .. oxy .. "hi",
= "IDva" .. oxy .. "m",
= "Ira" .. oxy .. "n"
}
},
= {
= "a" .. oxy .. "t",
= "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)
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, {
= {
= {
= "ye" .. oxy,
= "ya" .. oxy .. "se",
= "ya" .. oxy .. "te",
= "yA" .. oxy .. "vahe",
= "ye" .. oxy .. "Te",
= "ye" .. oxy .. "te",
= "yA" .. oxy .. "mahe",
= "ya" .. oxy .. "Dve",
= "ya" .. oxy .. "nte"
}
},
= {
= {
= "yE" .. oxy,
= "ya" .. oxy .. "sva",
= "ya" .. oxy .. "tAm",
= "yA" .. oxy .. "vahE",
= "ye" .. oxy .. "TAm",
= "ye" .. oxy .. "tAm",
= "yA" .. oxy .. "mahE",
= "ya" .. oxy .. "Dvam",
= "ya" .. oxy .. "ntam"
}
},
= {
= {
= "ye" .. oxy .. "ya",
= "ye" .. oxy .. "TAs",
= "ye" .. oxy .. "ta",
= "ye" .. oxy .. "vahi",
= "ye" .. oxy .. "yATAm",
= "ye" .. oxy .. "yAtAm",
= "ye" .. oxy .. "mahi",
= "ye" .. oxy .. "Dvam",
= "ye" .. oxy .. "rant"
}
},
= {
= "ya" .. oxy .. "mAna"
}
})
end
})
conj_data = {}
setmetatable(conj_data, {
__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, {
= {
= {
= "am",
= "as",
= "at",
= "Ava",
= "atam",
= "atAm",
= "Ama",
= "ata",
= "ant"
},
= {
= "e",
= "aTAs",
= "ata",
= "Avahi",
= "eTAm",
= "etAm",
= "Amahi",
= "aDvam",
= "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, {
= {
= {
= "am",
= "s",
= "t",
},
},
})
local weak_lemma = args.weak_lemma
local weak_stem = get_stem(weak_lemma, "(.+)an$")
make_forms(args, data, weak_stem, {
= {
= {
= "va",
= "tam",
= "tAm",
= "ma",
= "ta",
= "ant"
},
= {
= "i",
= "TAs",
= "ta",
= "vahi",
= "ATAm",
= "AtAm",
= "mahi",
= "Dvam",
= "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, {
= {
= {
= "ye",
= "yaTAs",
= "yata",
= "yAvahi",
= "yeTAm",
= "yetAm",
= "yAmahi",
= "yaDvam",
= "yanta"
}
},
})
end
})
conj_data = {}
setmetatable(conj_data, {
__call = function (self, args, data)
local make_strong_forms = function (oxy)
return {
= {
= {
= "syA" .. oxy .. "mi",
= "sya" .. oxy .. "si",
= "sya" .. oxy .. "ti",
= "syA" .. oxy .. "vas",
= "sya" .. oxy .. "Tas",
= "sya" .. oxy .. "tas",
= "syA" .. oxy .. "mas",
= "sya" .. oxy .. "Ta",
= "sya" .. oxy .. "nti"
},
= {
= "sye" .. oxy,
= "sya" .. oxy .. "se",
= "sya" .. oxy .. "te",
= "syA" .. oxy .. "vahe",
= "sye" .. oxy .. "Te",
= "sye" .. oxy .. "te",
= "syA" .. oxy .. "mahe",
= "sya" .. oxy .. "Dve",
= "sya" .. oxy .. "nte"
}
},
= {
= "sya" .. oxy .. "t",
= "syA" .. oxy .. "na"
}
}
end
local make_perph_forms = function (oxy)
return {
= {
= {
= "tA" .. oxy .. "smi",
= "tA" .. oxy .. "si",
= "tA" .. oxy,
= "tA" .. oxy .. "svas",
= "tA" .. oxy .. "sTas",
= "tA" .. oxy .. "rO",
= "tA" .. oxy .. "smas",
= "tA" .. oxy .. "sTa",
= "tA" .. oxy .. "ras"
},
= {
= "tA" .. oxy .. "he",
= "tA" .. oxy .. "se",
= "tA" .. oxy,
= "tA" .. oxy .. "svahe",
= "tA" .. oxy .. "sATe",
= "tA" .. oxy .. "rO",
= "tA" .. oxy .. "smahe",
= "tA" .. oxy .. "Dve",
= "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) do
make_forms(args, data, strong_stem, make_strong_forms(strong_stems))
end
local weak_lemma = args.weak_lemma or args.passive_lemma
if weak_lemma == nil then
for i, strong_stem in ipairs(strong_stems) do
make_forms(args, data, strong_stem, make_perph_forms(strong_stems))
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) do
make_forms(args, data, weak_stem, make_perph_forms(weak_stems))
end
end
end
})
conj_data = {}
setmetatable(conj_data, {
__call = function (self, args, data)
local strong_stems = get_stems_from_lemmas(
args.strong_lemma,
"(.+).yat$"
)
for i, strong_stem in ipairs(strong_stems) do
make_forms(args, data, strong_stem, {
= {
= {
= "syam",
= "syas",
= "syat",
= "syAva",
= "syatam",
= "syatAm",
= "syAma",
= "syata",
= "syant"
},
= {
= "sye",
= "syaTAs",
= "syata",
= "syAvahi",
= "syeTAm",
= "syetAm",
= "syAmahi",
= "syaDvam",
= "syanta"
}
}
})
end
end
})
conj_data = {}
setmetatable(conj_data, {
__call = function (self, args, data)
local strong_is_endings = {
= {
= {
= "izam",
= "Is",
= "It",
= "izva",
= "iztam",
= "izwAm",
= "izma",
= "izwa",
= "izus"
},
}
}
local weak_is_endings = {
= {
= {
= "izi",
= "izWAs",
= "izwa",
= "izvahi",
= "izATAm",
= "izAtAm",
= "izmahi",
= "iQvam",
= "izata"
},
}
}
local strong_s_endings = {
= {
= {
= "sam",
= "sIs",
= "sIt",
= "sva",
= "stam",
= "stAm",
= "sma",
= "sta",
= "sus"
},
}
}
local strong_ks_endings = {
= {
= {
= "sam",
= "sIs",
= "sIt",
= "sva",
= "tam",
= "tAm",
= "sma",
= "ta",
= "sus"
},
}
}
local weak_s_endings = {
= {
= {
= "si",
= "sTAs",
= "sta",
= "svahi",
= "sATAm",
= "sAtAm",
= "smahi",
= "Dvam",
= "sata"
},
}
}
local weak_ks_endings = {
= {
= {
= "si",
= "TAs",
= "ta",
= "svahi",
= "sATAm",
= "sAtAm",
= "smahi",
= "Dvam",
= "sata"
},
}
}
local strong_a_endings = {
= {
= {
= "am",
= "as",
= "at",
= "Ava",
= "atam",
= "atAm",
= "Ama",
= "ata",
= "ant"
},
}
}
local weak_a_endings = {
= {
= {
= "e",
= "aTAs",
= "ata",
= "Avahi",
= "eTAm",
= "etAm",
= "Amahi",
= "aDvam",
= "anta"
},
}
}
local strong_root_endings = {
= {
= {
= "am",
= "s",
= "t",
= "va",
= "tam",
= "tAm",
= "ma",
= "ta",
= "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)
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)
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 = {}
setmetatable(conj_data, {
__call = function (self, args, data)
local make_strong_forms = function (oxy)
return {
= {
= {
= "yA" .. oxy .. "sam",
= "yA" .. oxy .. "s",
= "yA" .. oxy .. "t",
= "yA" .. oxy .. "sva",
= "yA" .. oxy .. "stam",
= "yA" .. oxy .. "stAm",
= "yA" .. oxy .. "sma",
= "yA" .. oxy .. "sta",
= "yA" .. oxy .. "sus"
},
}
}
end
local make_weak_forms = function (oxy)
return {
= {
= {
= "sIya" .. oxy,
= "sIzWA" .. oxy .. "s",
= "sIzwa" .. oxy,
= "sIva" .. oxy .. "hi",
= "sIyA" .. oxy .. "sTAm",
= "sIyA" .. oxy .. "stAm",
= "sIma" .. oxy .. "hi",
= "sIDva" .. oxy .. "m",
= "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) do
make_forms(args, data, strong_stem, make_strong_forms(strong_stems))
end
local weak_lemma = args.weak_lemma or args.passive_lemma
if weak_lemma == nil then
for i, strong_stem in ipairs(strong_stems) do
make_forms(args, data, strong_stem, make_weak_forms(strong_stems))
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) do
make_forms(args, data, weak_stem, make_weak_forms(weak_stems))
end
end
end
})
conj_data = {}
setmetatable(conj_data, {
__call = function (self, args, data)
local make_strong_forms = function (oxy)
return {
= {
= {
= "a",
= "iTa",
= "a",
},
}
}
end
local make_weak_forms = function (oxy)
return {
= {
= {
= "iva" .. oxy,
= "a" .. oxy .. "Tus",
= "a" .. oxy .. "tus",
= "ima" .. oxy,
= "a" .. oxy,
= "u" .. oxy .. "s"
},
= {
= "e" .. oxy,
= "ize" .. oxy,
= "e" .. oxy,
= "iva" .. oxy .. "he",
= "A" .. oxy .. "Te",
= "A" .. oxy .. "te",
= "imA" .. oxy .. "he",
= "iDve" .. oxy,
= "ire" .. oxy
}
},
= {
= "vA" .. oxy .. "Ms",
= "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) do
make_forms(args, data, strong_stem, make_strong_forms(strong_stems))
end
local weak_lemma = args.weak_lemma or args.passive_lemma
if weak_lemma == nil then
for i, strong_stem in ipairs(strong_stems) do
make_forms(args, data, strong_stem, make_weak_forms(strong_stems))
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) do
make_forms(args, data, weak_stem, make_weak_forms(weak_stems))
end
end
end
})
conj_data = {}
setmetatable(conj_data, {
__call = function (self, args, data)
local make_strong_forms = function (oxy)
return {
= { "ya", "tavya" .. oxy, "anI" .. oxy .. "ya" },
= { "yA", "tavyA" .. oxy, "anI" .. oxy .. "yA" }
}
end
local make_weak_forms = function (oxy)
return {
= "tvA" .. oxy,
= "ta" .. oxy,
= "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) do
make_forms(args, data, strong_stem, {
= "tum"
})
strong_stem = gsub(strong_stem, sa_utils.accent, "")
make_forms(args, data, strong_stem, make_strong_forms(strong_stems))
local ya_form = #(data.forms) - 2 -- TODO: This is not a great way of doing this
local prov = split_xs(split_stems(args.strong_lemma))
data.forms = prov
data.forms = 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) do
make_forms(args, data, gsub(strong_stem, sa_utils.accent, ""), make_weak_forms(strong_stems))
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) do
make_forms(args, data, weak_stem, make_weak_forms(weak_stems))
end
end
end
})
return conj_data