Module:st-headword

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

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

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

local plural_rules = {
		    = { = {"mo",    "ba", 3},  = {"ngw",   "b", 4},  = {"ngo", "b", 4},  = { "mm",   "bab", 3},  = {"ʼm", "bab", 3}},
		   = { = {  "",   "bo", 1, "bo-"}},
		 = { = {  "mo",  "ma", 3}},
		    = { = {"mo",  "me", 3},  = {"mm", "meb", 3},  = {"ʼm", "meb", 3}},
		    = { = {"le", "ma", 3},  = {"", "ma", 1}},
		    = { = {"le", "di", 3, "li"}},
		    = { = {"se",   "di", 3, "li"},  = {"s", "di", 2, "li"},  = {"", "di", 1, "li"}},
		    = { = {  "",    "di", 1, "li"}},
		  = { = {  "",  "ma", 1}},
		 = { = { "bo",  "ma", 3}},
		 = { = {"mo", "me", 3}}
}

function export.noun(frame)
	local params = {
		 = {},
		 = {},
		 = {list = true}
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local categories = {}
	local head
	if not args then
		args = mw.title.getCurrentTitle().subpageText
		head = mw.title.getCurrentTitle().subpageText:gsub("^-", "") .. "<sup title=\"tones missing\">?</sup>"
		table.insert(categories, "Requests for tone in " .. lang:getCanonicalName() .. " noun entries")
	end
	
	assert(args, "head required")
	
	local class = args or "?"
	
	local data = {lang = lang, pos_category = "nouns", categories = categories, heads = {head or args}, genders = {"c" .. mw.text.split(class, "%/")}, 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
		
		assert(#args > 0, "No plurals!")
		
		if #args == 1 then
			table.insert(infl_plural, {term = args, genders = {plural_classes]}})
		elseif #args == 2 then
			table.insert(infl_plural, {term = args, genders = {plural_classes]}, qualifiers = {"South Africa"}})
			table.insert(infl_plural, {term = args, genders = {plural_classes]}, qualifiers = {"Lesotho"}})
		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
				if v then
					return {match_case(singular, v .. mw.ustring.sub(singular, v)),
					     	match_case(singular, v .. mw.ustring.sub(singular, v))}
				else
					return {match_case(singular, v .. mw.ustring.sub(singular, v))}
				end
			end
		end
	end
end

return export