Module:Chak-adj
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Chak-adj/documentation
export = {}
require("Module:Chak-adj/format")
m_params = require("Module:Parameters")
m_vars = require("Module:Variables")
m_cu = require("Module:Chak-utilities")
m_stru = require("Module:String utilities")
function export.get_forms(root_str,manual)
local forms = {}
local root = m_cu.parse_root(root_str,true)
local tail_str = root[#root]
table.remove(root,#root)
local split = mw.text.split(tail_str,"y")
local root_coda = string.gsub(split[1],"-","")
local tail = mw.text.split(split[2] or '',"-")
concat_root = table.concat(root)..root_coda
forms["pos.nom"] = concat_root.."ii"..(tail[2] or '')
forms["pos.acc"] = concat_root.."ii"..(tail[2] or '')..((tail[2] and 'i') or '')
forms["pos.gen"] = concat_root.."iiya"..(tail[2] or '')
forms["eq.nom"] = concat_root.."iir"..(tail[2] or '')..((tail[2] and 'i') or '')
forms["eq.acc"] = concat_root.."iir"..(tail[2] or '')..'i'
forms["eq.gen"] = concat_root.."ii"..((tail[2] and "r") or '')..(tail[2] or "yar")..((tail[2] and 'a') or '')
forms["comp.nom"] = concat_root.."ai"..(tail[2] or '')
forms["comp.acc"] = concat_root.."ai"..(tail[2] or '')..((tail[2] and 'a') or '')
forms["comp.gen"] = concat_root.."ai"..(tail[2] or 'ya')
forms["sup.nom"] = concat_root.."ai"..(tail[2] or '').."z"..((tail[2] and 'i') or '')
forms["sup.acc"] = concat_root..((tail[2] and "e") or "ai")..(tail[2] or '').."za"
forms["sup.gen"] = concat_root.."ai"..(tail[2] or '').."z"..((tail[2] and 'a') or '')
for k,v in pairs(forms) do
forms[k] = m_cu.assimilate(v)
end
for k,v in pairs(manual) do
if manual[k] ~= nil then
forms[k] = v
end
end
return forms
end
function export.show_declension(root,mod,others)
mod = mod or ''
local forms = {}
forms = export.get_forms(root..mod,others)
return m_stru.format(decl_table,forms)
end
function export.declension(frame)
local params = {
[1] = {alias_of = "root"},
[2] = {alias_of = "mod"},
["root"] = { default = m_vars.var('chak-root') },
["mod"] = { default = m_vars.var('chak-mod') },
}
local frame_args = frame:getParent().args
local args,others = m_params.process(frame_args,params,true)
return export.show_declension(args["root"],args["mod"],others)
end
function export.headword(frame)
local params = {
[1] = {alias_of = "root"},
[2] = {alias_of = "mod"},
["root"] = { default = m_vars.var('chak-root') },
["mod"] = { default = m_vars.var('chak-mod') },
}
local frame_args = frame:getParent().args
local args,others = m_params.process(frame_args,params,true)
local forms = export.get_forms(args["root"]..(args["mod"] or ''),others)
local output = ""
output = output.."(''equative nominative'' "..m_cu.l(forms["eq.nom"])..", ''comparative nominative'' "..m_cu.l(forms["comp.nom"])..", ''superlative nominative'' "..m_cu.l(forms["sup.nom"])
output = output.."'')''"
return output
end
return export