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 ='[[:en: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 ='[[:en:w:Akkadian_language#Verb_patterns|'..args.class..']]'})
		table.insert(categories, "阿卡德語" .. args.class .."類動詞" )
	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 = "延續形", dur})
	end
	if perf then 
		table.insert(inflections, {label = "完成形", perf })
	end
	if pret then
		table.insert(inflections, {label = "過去形", pret})
	end
	if imp then
		table.insert(inflections, {label = "祈使形", imp})
    end
    
    return headword.full_headword({
    	lang = lang,
    	pos_category = "動詞",
    	inflections = inflections,
    	categories = categories
    })
   
end
return export