Module:Trig-verbs

From The Languages of David J. Peterson
Revision as of 22:24, 27 September 2023 by Vaxjedi (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Trig-verbs/documentation

export = {}


satellites = {
	"au",
	"daun",
	"in",
	"klin",
	"of",
	"op",
	"raun",
	"thru",
	"we",
}

local function get_verb_parts(verb) 
	if not verb then
		return nil,nil
	end
	
	term = mw.text.trim(verb)
	root, sat = string.match(term,'(%S+)%s+(%S+)')
	
	return root or verb, sat or ''
end

local function getSatTable(root,sat,exclude)

	exclude = string.gsub(','..exclude..',',"%s+","")
	local lines = {}
	
	for _,value in ipairs(satellites) do
		if sat ~= value then
			if string.find(exclude,','..value..",") then
				table.insert(lines,"''"..root.." "..value.." (not used)")
			else
				table.insert(lines,'[['..root..' '..value..']]')
			end
		end
	end
	
	return lines
end

function export.showVerbSiblings(frame)
	
	local args = frame.getParent and frame:getParent().args or frame
	local exclude = args["exclude"] or ""
	
	local title = mw.title.getCurrentTitle()
	if title.nsText == "" then
		input = title.text
	else
		input = "test au"
	end
	
	root, sat = get_verb_parts(input) 
	
	local output = {}

	table.insert(output,'{| role="presentation" class="mw-collapsible mw-collapsed" style="background-color:#f0f0f0;width:50%;"\n')
    table.insert(output,'! style="font-weight:normal; background-color:#fafafa; |')
    table.insert(output," Verbs from root ''[["..(root or "unknown") .."]]''. \n|-\n| ")
	
	local sats = getSatTable(root,sat,exclude)
	
	return table.concat(output)..require("Module:Columns").create_list { 
			background_color = "#F8F8FF",
			column_count = 3,
			lang = require("Module:Languages").getByCode('trig'),
		    content = sats,
	}..'\n|}'
end
	
return export