Jump to content

Module:ikx-headword

From Wiktionary, the free dictionary

This module implements the following template:


local export = {}

local lang = require("Module:languages").getByCode("ikx")

function export.noun(frame)
	local params = {
		[1] = {},
		[2] = {},
		[3] = {}
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	if not args[1] then
		error("Please provide a headoword with the appropriate tone marks")
	end
	if not args[2] then
		error("Please provide a stem.")
	elseif args[2]:sub(-1) ~= "-" then
		error("The stem must end with a dash.")
	end

	local data = {lang = lang, pos_category = "nouns", categories = {}, heads = {args[1]}, inflections = {}}
	
	--insert the stem
	local stem = {label = "stem", {term = args[2], nolinkinfl = true}}
	table.insert(data.inflections, stem)
	
	--insert the plural, if it exists
	if args[3] then
		local plural = {label = "plural", args[3], request = true}
		table.insert(data.inflections, plural)
	end
	
	return require("Module:headword").full_headword(data)
end

return export