Module:swb-headword

Hello, you have come here looking for the meaning of the word Module:swb-headword. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:swb-headword, but we will also tell you about its etymology, its characteristics and you will know how to say Module:swb-headword in singular and plural. Everything you need to know about the word Module:swb-headword you have here. The definition of the word Module:swb-headword will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:swb-headword, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Used in {{swb-noun}}.


local export = {}

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

local plural_classes = {
	 = "c2",  = "c2",  = "c2",  = "c4",  = "c8",  = "c10",
	 = "c6",  = "c6",  = "c4",  = "c10"}

local plural_rules = {
		    = { = {"mw",    "w", 3},  = {"mu",   "wa", 3},  = {"m", "wa", 2}},
		   = { = {  "",   "wa", 1}},
		   = { = {  "",   "wa", 1}}, --a copy of 1a in case people prefer calling it this
		    = { = {"mu",  "mi", 3},  = {"mw", "m", 3},  = { "mo",  "me", 3},  = {"m", "mi", 2}},
		    = { = {"dzi", "ma", 4},  = {"ɗ", "mal", 2},  = {"k", "mah", 2},  = {"p", "mavh", 2},  = {"tr", "mar", 3},  = {"sh", "maz", 3},  = {"", "ma", 1}},
		    = { = {"sh",   "z", 3}},
		    = { = {  "",    "", 1}},
		  = { = {  "",  "ma", 1}},
	   	 = { = {  "u",  "mi", 2}},
	   	 = { = {  "u",  "ngu", 2},  = {"wa", "nya", 3},  = {"wi", "mbi", 3},  = {"wo", "mao", 3}}
}

function export.noun(frame)
	local params = {
		 = {required=true},
		 = {},
		 = {},
		 = {alias_of = "head"}
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local data = {lang = lang, pos_category = "nouns", categories = {}, heads = {args}, genders = {mw.text.split(args, "%/")}, inflections = {}}
	table.insert(data.categories, lang:getCanonicalName() .. " class " .. data.genders .. " nouns")
	
	if args ~= "-" and plural_classes] then
		local infl_plural = {label = "plural", accel = {form = "p", gender = plural_classes]}, request = true}
		
		-- If no plural was provided, generate one
		if not args then
			local singular = args and require("Module:links").remove_links(args) or mw.title.getCurrentTitle().text
			args = export.generate_plural(singular, args)
		end
		
		if args then	
			table.insert(infl_plural, {term = args, genders = {plural_classes]}})
		end
		
		table.insert(data.inflections, infl_plural)
	end
	
	return require("Module:headword").full_headword(data)
end


function match_case(string1, string2)
	local c1 = mw.ustring.sub(string1, 1, 1)
	local c2 = mw.ustring.sub(string2, 1, 1)
	
	if (mw.ustring.lower(c1) == c1) then
		return mw.ustring.lower(c2) .. mw.ustring.sub(string2, 2)
	else
		return mw.ustring.upper(c2) .. mw.ustring.sub(string2, 2)
	end
end


function export.generate_plural(singular, class)
	if plural_rules then
		for k, v in ipairs(plural_rules) do
			if mw.ustring.find(mw.ustring.lower(singular), "^" .. v) then
				return match_case(singular, v .. mw.ustring.sub(singular, v))
			end
		end
	end
end

return export