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).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 = {
= {
= {
= {"", "ቀተል", "ኩ"},
= {"", "ቀተል", "ከ"},
= {"", "ቀተል", "ኪ"},
= {"", "ቀተል", "ነ"},
= {"", "ቀተል", "ክሙ"},
= {"", "ቀተል", "ክን"}
},
= {
= {"እ", "ቀትል", ""},
= {"ት", "ቀትል", ""},
= {"ት", "ቀትሊ", ""},
= {"ይ", "ቀትል", ""},
= {"ት", "ቀትል", ""},
= {"ን", "ቀትል", ""},
= {"ት", "ቀትሉ", ""},
= {"ት", "ቀትላ", ""},
= {"ይ", "ቀትሉ", ""},
= {"ይ", "ቀትላ", ""}
},
= {},
= {}
},
= {
= {
= {"", "ቀተለ", ""},
= {"", "ቀተለ", "ት"},
= {"", "ቀተሉ", ""},
= {"", "ቀተላ", ""}
},
= {
= {"እ", "ቅትል", ""},
= {"ት", "ቅትል", ""},
= {"ት", "ቅትሊ", ""},
= {"ይ", "ቅትል", ""},
= {"ት", "ቅትል", ""},
= {"ን", "ቅትል", ""},
= {"ት", "ቅትሉ", ""},
= {"ት", "ቅትላ", ""},
= {"ይ", "ቅትሉ", ""},
= {"ይ", "ቅትላ", ""}
},
= {
= {"", "ቅትል", ""},
= {"", "ቅትሊ", ""},
= {"", "ቅትሉ", ""},
= {"", "ቅትላ", ""}
}
},
= {
= {
= {"", "ቀትለ", ""},
= {"", "ቀትለ", "ት"},
= {"", "ቀትሉ", ""},
= {"", "ቀትላ", ""}
},
= {
= {"እ", "ቅተል", ""},
= {"ት", "ቅተል", ""},
= {"ት", "ቅተሊ", ""},
= {"ይ", "ቅተል", ""},
= {"ት", "ቅተል", ""},
= {"ን", "ቅተል", ""},
= {"ት", "ቅተሉ", ""},
= {"ት", "ቅተላ", ""},
= {"ይ", "ቅተሉ", ""},
= {"ይ", "ቅተላ", ""}
},
= {
= {"", "ቅተል", ""},
= {"", "ቅተሊ", ""},
= {"", "ቅተሉ", ""},
= {"", "ቅተላ", ""}
}
}
}
function export.conj(root, stem, form, person)
local paradigm = {}
if stem == "Ga" or stem == "Gb" then
paradigm = conj_paradigms or conj_paradigms
else
paradigm = conj_paradigms
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