local lang = require("Module:languages").getByCode("akk")
local conj = require("Module:akk-conj")
local headword = require("Module:headword")
local export = {}



function export.main(frame) 
	local parent = frame:getParent()
    local args = parent.args
    
    args.stem = args[1]
    args.class = args[2]
    
    inflections = {}
    categories = {}
    
	if args.stem then 
		table.insert(inflections, { label ='[[w:Akkadian_language#Verb_patterns|'..args.stem..']]'})
		table.insert(categories, "Akkadian " .. args.stem .."-stem verbs" )
	else 
		table.insert(categories, "Akkadian verbs lacking stems")
	end
	
	if args.class then 
		table.insert(inflections, { label ='[[w:Akkadian_language#Verb_patterns|'..args.class..']]'})
		table.insert(categories, "Akkadian class " .. args.class .." verbs" )
	end
	
	local dur  = args.dur 
	local perf = args.perf
	local pret = args.pret
	local imp  = args.imp 
	local title = mw.title.getCurrentTitle().text
	
	local _, _, r1, r2, r3 = mw.ustring.find(title, "^(.)[ae](.)[āē](.)um$")
	
	if r1 and r2 and r3 and not args.root then
		args.root = r1 .. "-" .. r2 .. "-" .. r3
	end
		
    if args.stem == "G" and args.root then
    	local table_ = InflectionTable:from_args(args)
    	dur  = dur  or table_.dur[4]
    	perf = perf or table_.perf[4]
    	pret = pret or table_.pret[4]
    	imp  = imp  or table_.imp[2]
    end
    if dur then 
		table.insert(inflections, {label = "durative", dur})
	end
	if perf then 
		table.insert(inflections, {label = "perfect", perf })
	end
	if pret then
		table.insert(inflections, {label = "preterite", pret})
	end
	if imp then
		table.insert(inflections, {label = "imperative", imp})
    end
    
    return headword.full_headword({
    	lang = lang,
    	pos_category = "verbs",
    	inflections = inflections,
    	categories = categories
    })
   
end
return export