Module:bvb-headword

local export = {}

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

local plural_classes = { ["1"] = "c2", ["3"] = "c4", ["3/8"] = "c8", ["5"] = "c6", ["7"] = "c8", ["9"] = "c10", ["11"] = "c10", ["11/4"] = "c4", ["11/6"] = "c6", ["12"] = "c13", ["16"] = "c8"}

local valid_classes = { ["1"] = true, ["2"] = true, ["3"] = true, ["3/8"] = true, ["4"] = true, ["5"] = true, ["6"] = true, ["6b"] = true, ["7"] = true, ["8"] = true, ["9"] = true, ["10"] = true, ["11"] = true, ["11/4"] = true, ["11/6"] = true, ["12"] = true, ["13"] = true, ["15"] = true, ["16"] = true } function export.noun(frame) local params = { ["head"] = {}, [1] = {},		[2] = {}	}	local args = require("Module:parameters").process(frame:getParent.args, params) local categories = {} local class if not valid_classes[args[1]] then error("Please provide a valid class.") else class = mw.text.split(args[1], "%/")[1] end local data = {lang = lang, pos_category = "nouns", categories = categories, heads = {args["head"]}, genders = {"c" .. class}, inflections = {}} table.insert(data.categories, lang:getCanonicalName .. " class " .. class .. " nouns")

if args[2] ~= "-" and plural_classes[args[1]] then local infl_plural = {label = "plural", accel = {form = "p", gender = plural_classes[args[1]]}, request = true} -- If no plural was provided, generate one automatically. This is only done with class 9 (whose plurals in class 10 are identical) if args[1] == "9" then args[2] = args["head"] and require("Module:links").remove_links(args["head"]) or mw.title.getCurrentTitle.text elseif not args[2] then error("Please provide a plural or mark this noun as having no plural.") end table.insert(infl_plural, {term = args[2], genders = {plural_classes[args[1]]}}) table.insert(data.inflections, infl_plural) end return require("Module:headword").full_headword(data) end

return export