এই মডিউলের জন্য মডিউল:akk-conj/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local common = require("Module:akk-common")
local render = require("Module:akk-conj/table")
local g = {
    stem = require("Module:akk-conj/g/stem"), 
    endings = require("Module:akk-conj/g/endings"),
    weakness = require("Module:akk-conj/g/weakness")
}

local export = {}

local InflectionTable = {}
function InflectionTable:new(stems, endings)
    local object = {
        number = self:number(), 
        dur    = endings:dur(stems.dur1, stems.dur2),
        pret   = endings:pret(stems.pret1, stems.pret2),
        perf   = endings:perf(stems.perf1, stems.perf2),
        imp    = endings:imp(stems),
        inf    = endings:nominal(stems.inf),
        part   = endings:nominal(stems.part),
        adj    = endings:nominal(stems.adj),
    } 
    setmetatable(object, {__index = self})
    return object
end

function InflectionTable:number() 
    return  {
        {"1.sg"}, 
        {"2.sg", "m"}, 
        {"2.sg", "f"}, 
        {"3.sg"}, 
        {"1.pl"}, 
        {"2.pl"}, 
        {"3.pl", "m"}, 
        {"3.pl", "f"},
    }
end

function InflectionTable:render(stem_name)
    if stem_name == nil or stem_name == "" then
        error("A stem must be specified")
    end
    return render.render(stem_name, self)
end


function parse_root(root) 
	if not root then
		error("A root must be specified under the parameter `root`. e.g: {{akk-conj|G|root=p-r-s|class=a-u}}") 
	end
	local R = {}
	local i = 0
	for r in mw.ustring.gmatch(root, "(.)[-]?") do 
		i = i + 1
		R[i] = r
	end
	return R
end

local function override(table_, args)
	local keys = {
		["1sg"]   = 1, 
        ["2sgm"] = 2, 
        ["2sgf"] = 3, 
        ["3sg"]   = 4, 
        ["1pl"]   = 5, 
        ["2pl"]   = 6, 
        ["3plm"] = 7, 
        ["3plf"] = 8,
	}
	for name, value in pairs(args) do
		if type(name) == "string" then
			local iter   = mw.ustring.gmatch(name, "[^\\.]+") 
			local tense  = iter() or ""
			local person = iter() or ""
			local number = iter() or ""
			local gender = iter() or ""
			local array = table_[tense]
			if type(array) == "table" then
				array[keys[person..number..gender]] = value
			end
		end
		
	end
	
end

function export.main(frame, raw) 
    local args = frame:getParent().args
    -- positional argument support 
    args.stem = args.stem or args[1]
    args.root = args.root or args[2]
    args.class = args.class or args[3]
    
    if args.stem == "G" then 
        local root = parse_root(args.root)
        local weakness = g.weakness(root, args.class)
        local stem = g.stem(root, args.class, args)
        local endings = g.endings(weakness)
        local table = InflectionTable:new(stem, endings)
        override(table, args)
        if raw then
            return table
        else
            return table:render("G-stem "..(weakness or "sound"), args.debug)
        end
        
    elseif args.stem == "D" then 
        error("Not yet implemented")
    elseif args.stem == "Š" then 
        error("Not yet implemented")
    elseif args.stem == "N" then 
        error("Not yet implemented")
    elseif args.stem == "Gt" then 
        error("Not yet implemented")
    elseif args.stem == "Dt" then 
        error("Not yet implemented")
    elseif args.stem == "Št" then 
        error("Not yet implemented")
    elseif args.stem == "Nt" then 
        error("Not yet implemented")
    elseif args.stem == "Gtn" then 
        error("Not yet implemented")
    elseif args.stem == "Dtn" then 
        error("Not yet implemented")
    elseif args.stem == "Ntn" then 
        error("Not yet implemented")
    elseif args.stem == "Štn" then 
        error("Not yet implemented")
    else 
        error("Not a valid Akkadian stem.")
    end
end

return export