Jump to content

Module:akk-verb

From Wiktionary, the free dictionary


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



function get_root(args) 
	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
		return {r1, r2 ,r3}
	end
	
	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
		return {r1, r2 ,r3}
	end
	
	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
		return {r1, r2 ,r3}
	end
	
	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
		return {r1, r2 ,r3}
	end
	
	local _, _, r1, r2, r3 = mw.ustring.find(title, "^(.)i?([āâēê])(.)um$")
	
	if r1 and r2 and r3 and not args.root then
		r2 = mw.ustring.gsub(r2, "[āâ]", "a")
		r2 = mw.ustring.gsub(r2, "[ēê]", "e")
		args.root = r1 .. "-" .. r2 .. "-" .. r3
		return {r1, r2 ,r3}
	end
	
	local _, _, r1, r2 = mw.ustring.find(title, "^(.)[ea](.)ûm$")
	if r1 and r2 and not args.root then
		local r3 = mw.ustring.gsub(args.class, "i", "y")
		r3 = mw.ustring.gsub(r3, "u", "w")
		args.root = r1 .. "-" .. r2 .. "-" .. r3
		return {r1, r2 , r3}
	end
	
end

function export.main(frame) 
	local parent = frame:getParent()
    local args = parent.args
    
    args.stem = args[1]
    args.class = args[2]
    
    get_root(args)
    
    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 
	
		
    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