Module:User:iwsfutcmd/gez-verbal

local sub = mw.ustring.sub local split = mw.text.split local com = require('Module:Ethi-common')

local export = {}

local function o(char, new_order) local c = com.to_components(char) c.order = new_order return com.from_components(c) end

local function apply_orders(string, order_string) local output = {} local order_chars = split(order_string, "") for i, c in ipairs(split(string, "")) do       table.insert(output, o(c, com.to_components(order_chars[i]).order)) end return table.concat(output) end

local function assimilate_suffix(base, suffix) local final_c = o(sub(base, -1), com.to_components(sub(suffix, 1, 1)).order) return sub(base, 1, -2) .. final_c .. sub(suffix, 2) end

local conj_paradigms = { ["G"] = { ["pf"] = { ["1s"] = {"", "ቀተል", "ኩ"}, ["2ms"] = {"", "ቀተል", "ከ"}, ["2fs"] = {"", "ቀተል", "ኪ"}, ["1p"] = {"", "ቀተል", "ነ"}, ["2mp"] = {"", "ቀተል", "ክሙ"}, ["2fp"] = {"", "ቀተል", "ክን"} },       ["impf"] = { ["1s"] = {"እ", "ቀትል", ""}, ["2ms"] = {"ት", "ቀትል", ""}, ["2fs"] = {"ት", "ቀትሊ", ""}, ["3ms"] = {"ይ", "ቀትል", ""}, ["3fs"] = {"ት", "ቀትል", ""}, ["1p"] = {"ን", "ቀትል", ""}, ["2mp"] = {"ት", "ቀትሉ", ""}, ["2fp"] = {"ት", "ቀትላ", ""}, ["3mp"] = {"ይ", "ቀትሉ", ""}, ["3fp"] = {"ይ", "ቀትላ", ""} },       ["juss"] = {}, ["imp"] = {} },   ["Ga"] = { ["pf"] = { ["3ms"] = {"", "ቀተለ", ""}, ["3fs"] = {"", "ቀተለ", "ት"}, ["3mp"] = {"", "ቀተሉ", ""}, ["3fp"] = {"", "ቀተላ", ""} },       ["juss"] = { ["1s"] = {"እ", "ቅትል", ""}, ["2ms"] = {"ት", "ቅትል", ""}, ["2fs"] = {"ት", "ቅትሊ", ""}, ["3ms"] = {"ይ", "ቅትል", ""}, ["3fs"] = {"ት", "ቅትል", ""}, ["1p"] = {"ን", "ቅትል", ""}, ["2mp"] = {"ት", "ቅትሉ", ""}, ["2fp"] = {"ት", "ቅትላ", ""}, ["3mp"] = {"ይ", "ቅትሉ", ""}, ["3fp"] = {"ይ", "ቅትላ", ""} },       ["imp"] = { ["2ms"] = {"", "ቅትል", ""}, ["2fs"] = {"", "ቅትሊ", ""}, ["2mp"] = {"", "ቅትሉ", ""}, ["2fp"] = {"", "ቅትላ", ""} }   },    ["Gb"] = { ["pf"] = { ["3ms"] = {"", "ቀትለ", ""}, ["3fs"] = {"", "ቀትለ", "ት"}, ["3mp"] = {"", "ቀትሉ", ""}, ["3fp"] = {"", "ቀትላ", ""} },       ["juss"] = { ["1s"] = {"እ", "ቅተል", ""}, ["2ms"] = {"ት", "ቅተል", ""}, ["2fs"] = {"ት", "ቅተሊ", ""}, ["3ms"] = {"ይ", "ቅተል", ""}, ["3fs"] = {"ት", "ቅተል", ""}, ["1p"] = {"ን", "ቅተል", ""}, ["2mp"] = {"ት", "ቅተሉ", ""}, ["2fp"] = {"ት", "ቅተላ", ""}, ["3mp"] = {"ይ", "ቅተሉ", ""}, ["3fp"] = {"ይ", "ቅተላ", ""} },       ["imp"] = { ["2ms"] = {"", "ቅተል", ""}, ["2fs"] = {"", "ቅተሊ", ""}, ["2mp"] = {"", "ቅተሉ", ""}, ["2fp"] = {"", "ቅተላ", ""} }   } }

function export.conj(root, stem, form, person) local paradigm = {} if stem == "Ga" or stem == "Gb" then paradigm = conj_paradigms["G"][form][person] or conj_paradigms[stem][form][person] else paradigm = conj_paradigms[stem][form][person] end local prefix, order_string, suffix = unpack(paradigm) local base = prefix .. apply_orders(root, order_string) local final_base_c = sub(base, -1) local initial_suffix_c = sub(suffix, 1, 1) if (final_base_c == "ክ" or final_base_c == "ግ" or final_base_c == "ቅ") and com.to_components(initial_suffix_c).base == "ከ" then return assimilate_suffix(base, suffix) elseif (final_base_c == "ን") and com.to_components(initial_suffix_c).base == "ነ" then return assimilate_suffix(base, suffix) else return prefix .. apply_orders(root, order_string) .. suffix end end

return export