Module:rw-headword

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


local export = {}

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

local MACRON = mw.ustring.char(0x0304)
local ACUTE = mw.ustring.char(0x0301)
local CIRCUMFLEX = mw.ustring.char(0x0302)

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

local plural_rules = {
		    = { = {"umw",  "ab", 4},  = {"umu",   "aba", 4},  = {"mu", "ba", 3},  = {"mw", "b", 3}},
		   = { = {  "",   "bā", 1}},
		    = { = {"umw",  "imy", 4},  = {"umu",   "imi", 4},  = {"mu", "mi", 3},  = {"mw", "my", 3}},
		    = { = {"i", "ama", 2},  = {"iry", "am", 4},  = {"ry", "m", 3},  = {"", "ma", 1}},
		    = { = {  "",    "", 1}},
		    = { = {"iki",   "ibi", 4},  = {"igi", "ibi", 4},  = {"icy", "iby", 4},  = {"ic", "ivy", 3},  = {"ki", "bi", 3},  = {"gi", "bi", 3},  = {"cy", "by", 3},  = {"c", "vy", 2}},
		    = { = {  "",    "", 1}},
		  = { = {  "i",  "ama", 2},  = {"","ama",1}},
		  = { = {"", "] ",1}},
	 	  = { = {"uruh", "imp", 5},  = {"urub", "imb", 5},  = {"urup", "imp", 5},  = {"urum", "im", 5},  = {"uruf", "imf", 5},  = {"uruv", "imv", 5},  = {"urw", "inz", 4},  = {"uruy", "inz", 5},  = {"uruny", "iny", 6},  = {"urur", "ind", 5},  = {"urun", "in", 5},  = {"uru", "in", 4}},--fails for urū > inzū
	 	  = { = {"uru","ama", 4}},
	 	  = { = {"uru","ubu", 4},  = {"urw", "ubw", 4}},
	 	  = { = {"aka", "utu", 4},  = {"aga", "udu", 4},  = {"ak", "utw", 3},  = {"ka", "tu", 3},  = {"ga", "du", 3},  = {"k", "tw", 2}},
		 = { = {  "ubu",  "ama", 4},  = {"ubw", "am", 4},  = {"ub", "am", 3},  = {"bu", "ma", 3},  = {"bw", "m", 3},  = {"b","m", 2}},
		 = { = {"uku", "ama", 4},  = {"ugu", "ama", 4},  = {"ukw", "am", 4},  = {"ugw", "am", 4},  = {"ku", "ma", 3},  = {"gu", "ma", 3},  = {"kw", "m", 3},  = {"gw", "m", 3}}
}

function export.noun(frame)
	local params = {
		 = {},
		 = {},
		 = {}
	}
	
	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
	
	local class
	if args then
		class = mw.text.split(args, "%/")
	else
		class = "?"
	end
	
	local data = {lang = lang, pos_category = "nouns", categories = categories, heads = {head or args}, genders = {"c" .. class}, inflections = {}}
	
	if class ~= "?" then
		table.insert(data.categories, lang:getCanonicalName() .. " class " .. class .. " nouns")
	end
	
	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
		
		table.insert(infl_plural, {term = args, genders = {plural_classes]}})
		
		table.insert(data.inflections, infl_plural)
	end
	
	return require("Module:headword").full_headword(data)
end

function export.verb(frame)
	local params = {
		 = {},
		 = {list = true},
		 = {}
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local categories = {}
	local inflections = {}
	local inf_forms = {label = "infinitive"}
	
	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() .. " verb entries")
	else
		head = "-" .. args
	end
	
	-- Generate infinitive form
	local inf_prefix = "ku"
	local root = mw.ustring.toNFD(args)
	local infinitive
	
	if args then
		table.insert(inf_forms, args)
	elseif mw.ustring.find(root, "^") then
		inf_prefix = "gu"
		infinitive = mw.ustring.toNFC(inf_prefix .. root)
		table.insert(inf_forms, infinitive)
	elseif mw.ustring.find(root, "^") then
		inf_prefix = "kw"
		local vowel = mw.ustring.sub(root, 1, 1)
		if mw.ustring.sub(root, 2, 2) == ACUTE then
			infinitive = mw.ustring.toNFC(inf_prefix .. mw.ustring.gsub(root, ACUTE, CIRCUMFLEX, 1))
		elseif mw.ustring.sub(root, 2, 2) == CIRCUMFLEX or mw.ustring.sub(root, 2, 2) == MACRON then
			infinitive = mw.ustring.toNFC(inf_prefix .. root)
		else
			infinitive = mw.ustring.toNFC(inf_prefix .. vowel .. MACRON .. mw.ustring.sub(root, 2))
		end
		
		if mw.ustring.lower(vowel) == "o" or mw.ustring.lower(vowel) == "u" then
			table.insert(inf_forms, {term = mw.ustring.gsub(infinitive, "^kw", "k"), q = {"Rwanda"}})
			table.insert(inf_forms, {term = infinitive, q = {"Rundi"}})
		else
			table.insert(inf_forms, infinitive)
		end
	else
		infinitive = mw.ustring.toNFC(inf_prefix .. root)
		table.insert(inf_forms, infinitive)
	end
	
	table.insert(inflections, inf_forms)
	
	-- perfective stem
	local perf_stem = nil
	if args then
		local perf_forms = {label = "perfective"}
		for _, form in ipairs(args) do
			perf_stem = "-" .. form
			table.insert(perf_forms, {term = perf_stem, nolink = true})
		end
		table.insert(inflections, perf_forms)
	else -- generate perfective stem if possible
		local perf_forms = {label = "perfective"}
		root = mw.ustring.gsub(root, "a$", "") -- remove final vowel -a
		local is_generated = false
		if mw.ustring.find(root, "") then -- exclude -CV- roots
			is_generated = true
			-- regular changes
			if mw.ustring.find(root, "c$") then
				perf_stem = "-" .. mw.ustring.gsub(root, "c$", "she")
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "d$") then
				perf_stem = "-" .. mw.ustring.gsub(root, "d$", "ze")
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "g$") then
				perf_stem = "-" .. mw.ustring.gsub(root, "g$", "ze")
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "nk$") then
				perf_stem = "-" .. mw.ustring.gsub(root, "nk$", "nse")
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "k$") then
				perf_stem = "-" .. mw.ustring.gsub(root, "k$", "tse")
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif root == "fat" then -- one irregular case (gufata)
				perf_stem = "-fashe"
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "t$") then
				perf_stem = "-" .. mw.ustring.gsub(root, "t$", "se")
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "y$") then
				perf_stem = "-" .. root .. "e"
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "m$") then
				perf_stem = "-" .. root .. "ye"
				table.insert(perf_forms, {term = perf_stem, nolink = true})
			elseif mw.ustring.find(root, "b$") then
				local perf_stem_rw = "-" .. root .. "ye"
				table.insert(perf_forms, {term = perf_stem_rw, q = {"Rwanda"}, nolink = true})
				local perf_stem_rn = "-" .. mw.ustring.gsub(root, "b$", "vye")
				table.insert(perf_forms, {term = perf_stem_rn, q = {"Rundi"}, nolink = true})
			elseif mw.ustring.find(root, "h$") then
				local perf_stem_rw = "-" .. mw.ustring.gsub(root, "h$", "shye")
				table.insert(perf_forms, {term = perf_stem_rw, q = {"Rwanda"}, nolink = true})
				local perf_stem_rn = "-" .. mw.ustring.gsub(root, "h$", "she")
				table.insert(perf_forms, {term = perf_stem_rn, q = {"Rundi"}, nolink = true})
			else
				is_generated = false
			end
		end
		
		if not is_generated then
			table.insert(perf_forms, {term = nil, nolink = true})
		end
		
		table.insert(inflections, perf_forms)
	end
	
	local data = {lang = lang, pos_category = "verbs", categories = categories, heads = {head}, inflections = inflections}
	
	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
		singular = mw.ustring.toNFD(singular)
		for k, v in ipairs(plural_rules) do
			if mw.ustring.find(mw.ustring.lower(singular), "^" .. v) then
				local plural = match_case(singular, v .. mw.ustring.sub(singular, v))
				return mw.ustring.toNFC(plural)
			end
		end
	end
end

return export