Module:sw-conj/sandbox

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


local m_links = require("Module:links")
local m_utils = require("Module:utilities")
local lang = require("Module:languages").getByCode("sw")

PAGENAME = mw.title.getCurrentTitle().text or ''
local export = {}

local o_of_reference = {
	"ye", "o", "yo", "lo", "cho", "vyo", "zo", "ko", "po", "mo"
}

local obj_infixes = {
	"ni", "ku", "m", "tu", "wa", "ji", "u", "i", "li", "ya", "ki", "vi", "zi", "pa", "mu"
}

local irreg_kw_inf = {
	 = true,
	 = true,
	 = true,
}

local subj_list = {
	"1s", "2s", "3s", "1p", "2p", "3p",
	"3c", "4c", "5c", "6c", "7c", "8c", "9c", "10c", "11c", "15c", "16c", "18c",
}

local subjects = {
	 = {
		 = {"ni"},
		 = {"u"},
		 = {"a"},
		 = {"tu"},
		 = {"m"},
		 = {"wa"},
		 = {"u"},
		 = {"i"},
		 = {"li"},
		 = {"ya"},
		 = {"ki"},
		 = {"vi"},
		 = {"i"},
		 = {"zi"},
		 = {"u"},
		 = {"ku"},
		 = {"pa"},
		 = {"mu"},
	},
	 = {
		 = {"si"},
		 = {"hu"},
		 = {"ha"},
		 = {"hatu"},
		 = {"ham"},
		 = {"hawa"},
		 = {"hau"},
		 = {"hai"},
		 = {"hali"},
		 = {"haya"},
		 = {"haki"},
		 = {"havi"},
		 = {"hai"},
		 = {"hazi"},
		 = {"hau"},
		 = {"haku"},
		 = {"hapa"},
		 = {"hamu"},
	},
	 = {
		 = {"n"},
		 = {"w"},
		 = {""},
		 = {"tw"},
		 = {"mw"},
		 = {"w"},
		 = {"w"},
		 = {"y"},
		 = {"l"},
		 = {"y"},
		 = {"ch"},
		 = {"vy"},
		 = {"y"},
		 = {"z"},
		 = {"w"},
		 = {"kw"},
		 = {"p"},
		 = {"mw"},
	},
}
subjects.r = subjects.p

local tam = {
	 = {
		 = {{
			"li",
			alt = {
				 = {"ni", "na"},
				 = {"u", "wa"},
				 = {"tu", "twa"},
				 = {"m", "mwa"}
			},
			mono = true,
		}},
		 = {{
			"lio",
			alt = {
				 = {"ni", "na"},
				 = {"u", "wa"},
				 = {"tu", "twa"},
				 = {"m", "mwa"}
			},
			mono = true,
		}},
		 = {{"ku"}},
	},
	 = {
		 = {{
			"na",
			alt = {
				 = {"ni", ""}
			},
			mono = true,
		}},
		 = {{
			"nao",
			alt = {
				 = {"ni", ""}
			},
			mono = true,
		}},
		 = {{
			"",
			final = "i",
			mono = true,
		}},
	},
	 = {
		 = {{
			"ta",
			mono = true,
		}},
		 = {{
			"takao",
			mono = true,
		}},
		 = {{
			"ta",
			mono = true,
		}},
	},
	 = {
		 = {{
			"nge",
			mono = true,
		}},
		 = {
			{
				"singe",
				alt = subjects.p,
				mono = true,
			},
			{
				"nge",
				alt = subjects.n,
				mono = true,
			}
		}
	},
	 = {
		 = {{
			"ngali",
			mono = true,
		}},
		 = {
			{
				"singali",
				alt = subjects.p,
				mono = true,
			},
			{
				"ngali",
				alt = subjects.n,
				mono = true,
			}
		}
	},
	 = {
		 = {{
			"ngeli",
			mono = true,
		}},
	},
	 = {
		 = {{
			"me",
			mono = true,
		}},
	},
	 = {
		 = {{
			"mesha",
			mono = true,
		}},
	},
	 = {
		 = {{"ki"}},
	},
	 = {
		 = {{"ka"}},
	},
	 = {
		 = {{
			"a",
			alt = subjects.cont,
		}},
	},
	 = {
		 = {{"ja"}},
	},
	 = {
		 = {{
			"sipo",
			alt = subjects.p,
			mono = true,
		}},
	},
	 = {
		 = {{
			"",
			final = "e"
		}},
		 = {{
			"si",
			final = "e",
			alt = subjects.p,
		}},
	},
	 = {
		 = {{
			"",
			final = "ao",
		}},
		 = {{
			"sio",
			alt = subjects.p,
			mono = true,
		}},
	},
}
local tamcopy = tam

function tablelength(T)
  local count = 0
  for _ in pairs(T) do count = count + 1 end
  return count
end

local function get_stem(lemma, args)
	if not mw.ustring.match(lemma, "a$") then
		-- Arabic verb
		return lemma, true, false, {"Swahili verbs in the Arabic conjugation"}
	elseif mw.ustring.match(lemma, "^+a$") or args.mono ~= nil then
		-- Monosyllabic
		return mw.ustring.gsub(lemma, "^(.*)a$", "%1"), false, true, {"Swahili verbs in the monosyllabic conjugation"}
	else
		-- Normal verbs
		return mw.ustring.gsub(lemma, "^(.*)a$", "%1"), false, false, {}
	end
end

local function link(term, accel_optional)
	if accel_optional then
		return m_links.full_link({lang = lang, term = term, allowSelfLink = false, accel = {form = accel_optional} })
	else
		return m_links.full_link({lang = lang, term = term, allowSelfLink = false})
	end
end

local function user_specified(text)
	if text == '-' then
		return '—'
	else
		local temp = {}
		for i, term in ipairs(mw.text.split(text, '/')) do
			table.insert(temp, link(term))
		end
		return table.concat(temp, '<br/>')
	end
end

local function setDefault (t, d)
	local mt = {__index = function () return d end}
	setmetatable(t, mt)
end

local output_subj_accel = {
	 = "m-mi|singular",
	 = "m-mi|plural",
	 = "ji-ma|singular",
	 = "ji-ma|plural",
	 = "ki-vi|singular",
	 = "ki-vi|plural",
	 = "n-n|singular",
	 = "n-n|plural",
	 = "u-n|singular",
	 = "ku",
	 = "pa",
	 = "mu",
}
setDefault(output_subj_accel, "")

local addition_accel = {
	 = "m-wa|singular",
	 = "m-wa|plural",
	 = "u-n|plural",
	 = "ku-loc",
}
setDefault(addition_accel, "")

local tampol_accel = {
	 = "|present",
	 = "|present|negative",
	 = "|perfect",
	 = "|gnomic",
	 = "|subjunctive",
	 = "|subjunctive|negative",
	 = "|past",
	 = "|past|negative",
	 = "|future",
	 = "|future|negative",
	 = "|consecutive",
	 = "|conditional",
	 = "|situational",
}
setDefault(tampol_accel, "")

local function make_accel(subj_name, tam, pol)
	output_subj = output_subj_accel
	output_subj = output_subj ~= "" and output_subj or subj_name
	addition = addition_accel
	tampol = tampol_accel
	accel_keywords = nil
	if tampol ~= "" then
		accel_keywords = "verb:|" .. output_subj .. tampol
		if addition ~= "" then
			accel_keywords = accel_keywords .. "|;|" .. addition .. tampol
		end
	end
	return accel_keywords
end

local function make_forms(args, lemma, stem, arabic, monosyllabic)
	local tag, temp, form, subjs
	local forms = {}
	
	local inf, inf_stem = table.concat{'ku', lemma}, table.concat{'ku', stem}
	if args.inf then
		forms.inf = user_specified(args.inf)
	elseif irreg_kw_inf then
		inf, inf_stem = table.concat{'kw', lemma}, table.concat{'kw', stem}
		forms.inf = link(inf)
	else
		forms.inf = link(inf)
	end
	
	if args.inf_n then
		forms.inf_n = user_specified(args.inf_n)
	elseif monosyllabic then
		forms.inf_n = link(table.concat{'kuto', inf})
	else
		forms.inf_n = link(table.concat{'kuto', lemma})
	end
	
	if args.hab then
		forms.hab = user_specified(args.hab)
	else
		forms.hab = link(table.concat{'hu', lemma})
	end
	
	if args.imp_s then
		forms.imp_s = user_specified(args.imp_s)
	elseif arabic then
		forms.imp_s = link(lemma)
	elseif monosyllabic then
		forms.imp_s = link(inf)
	else
		forms.imp_s = link(lemma)
	end
	
	if args.imp_p then
		forms.imp_p = user_specified(args.imp_p)
	elseif arabic then
		forms.imp_p = link(table.concat{lemma, 'ni'})
	elseif monosyllabic then
		forms.imp_p = link(table.concat{inf_stem, 'eni'})
	else
		forms.imp_p = link(table.concat{stem, 'eni'})
	end
	
	forms.title = table.concat{"''-", lemma, "''"}
	
	for _, infix in ipairs(obj_infixes) do
		tagfix = infix
		lemmafix = lemma
		if infix == "m" and string.match(string.sub(lemma, 1, 1), "") then
			infix = "mw"
		end
		forms = 'ku' .. infix .. lemma
		forms = 'hu' .. infix .. lemma
		if infix == "ku" or infix == "wa" then -- -eni/-ni ending
			if string.sub(lemma, -1) == "a" then
				lemmafix = string.reverse(string.gsub(string.reverse(lemma), 'a', 'e', 1))
			end
			forms = forms .. '<br/>' .. 'ku' .. infix .. lemmafix .. 'ni'
			forms = forms .. '<br/>' .. 'hu' .. infix .. lemmafix .. 'ni'
		end
	end
	
	for tam, tam_val in pairs(tam) do
		for pol, pols in pairs(tam_val) do
			for _, subj_name in ipairs(subj_list) do
				tag = table.concat({tam, pol, subj_name}, '_')
				temp = {}
				if args ~= nil then -- user specified
					forms = user_specified(args)
				else
					for _, pol_val in ipairs(pols) do
						if pol_val.alt and pol_val.alt then
							subjs = pol_val.alt
						else
							subjs = subjects
						end
						for _, subj in ipairs(subjs) do
							accel_keywords = nil
							form = {}
							-- subject marker
							table.insert(form, subj)
							-- tam
							table.insert(form, pol_val)
							-- stem
							if monosyllabic and pol_val.mono and not (pol == 'n' and tam == 'pres') then
								table.insert(form, inf_stem)
							else
								table.insert(form, stem)
							end
							-- suffix
							if arabic then
								table.insert(form, "")
							elseif pol_val.final then
								table.insert(form, pol_val.final)
							else
								table.insert(form, "a")
							end
							if (tam == "past" and pol == "r") or (tam == "pres" and pol == "r") or (tam == "fut" and pol == "r") or (tam == "rel" and pol == "p") or (tam == "rel" and pol == "n") then
								if tam == "rel" and pol == "p" then
									oindex = 4
								else
									oindex = 2
								end
								for _, o in ipairs(o_of_reference) do
									relform = {}
									for k, v in pairs(form) do
    									relform = v
									end
									if tam == "rel" and lemma == "wa" then
										if pol == "p" then
											relform = "li"
											relform = "o"
										end
										if pol == "n" then
											relform = ""
											relform = ""
										end
									end
									relform = string.gsub(relform, "o", o)
									if forms ~= nil then -- handles alt forms "na" vs "nina", etc
										forms = forms .. '<br/>' .. table.concat(relform)
									else
										forms = table.concat(relform) -- link(table.concat(relform))
									end
									if oindex == 2 and string.sub(relform, 1, 1) == "i" then -- double i as in "aliyoiita"
										relform = string.gsub(relform, o, o .. "i")
										forms = forms .. '<br/>' .. table.concat(relform) -- link(table.concat(relform))
									end
									if lemma == "wa" and (tam == "rel" or tam == "past" or tam == "fut") then -- special case locative options for -wa
										forms = forms .. '<br/>' .. table.concat(relform) .. 'po'
										forms = forms .. '<br/>' .. table.concat(relform) .. 'ko'
										forms = forms .. '<br/>' .. table.concat(relform) .. 'mo'
									end
								end
							end
							for _, infix in ipairs(obj_infixes) do
								obji = infix
								objform = {}
								for k, v in pairs(form) do
    								objform = v
								end
								if infix == "m" and string.match(string.sub(objform, 1, 1), "") then
									infix = "mw"
								end
								objform = objform .. infix
								if forms ~= nil then -- handles alt forms "na" vs "nina", etc
									forms = forms .. '<br/>' .. table.concat(objform)
								else
									forms = table.concat(objform) -- link(table.concat(objform))
								end
								if infix == "ku" or infix == "wa" then -- -eni/-ni ending
									if string.sub(objform, -1) == "a" then
										objform = string.gsub(objform, "a", "e")
									end
									objform = objform .. "ni"
									forms = forms .. '<br/>' .. table.concat(objform) -- link(table.concat(objform))
								end
							end
							accel_keywords = make_accel(subj_name, tam, pol)
							if accel_keywords == "" then
								table.insert(temp, link(table.concat(form)))
							else
								table.insert(temp, link(table.concat(form), accel_keywords))
							end
						end
					end
					forms = table.concat(temp, "<br/>")
				end
			end
		end
	end
	return forms
end

function export.show(frame)
	if
		mw.title.getCurrentTitle().nsText == "Template" and
		tablelength(frame:getParent().args) == 0 
	then
		return frame:expandTemplate{title= 'sw-conj/table', args = {}}
	end
	
	local args = frame:getParent().args or {}
	
	local lemma = args or PAGENAME
	local stem, arabic, monosyllabic, cat = get_stem(lemma, args)
	
	return frame:expandTemplate{
		title= 'sw-conj/table',
		args = make_forms(args, lemma, stem, arabic, monosyllabic)
		} .. m_utils.format_categories(cat, lang)
end

function export.show_sandbox(frame)
	if
		mw.title.getCurrentTitle().nsText == "Template" and
		tablelength(frame:getParent().args) == 0 
	then
		return frame:expandTemplate{title= 'sw-conj/table/sandbox', args = {}}
	end
	
	local args = frame:getParent().args or {}
	
	local lemma = args or PAGENAME
	local stem, arabic, monosyllabic, cat = get_stem(lemma, args)
	
	return frame:expandTemplate{
		title= 'sw-conj/table/sandbox',
		args = make_forms(args, lemma, stem, arabic, monosyllabic)
		} .. m_utils.format_categories(cat, lang)
end

function export.show_pres_prn(frame)
	if
		mw.title.getCurrentTitle().nsText == "Template" and
		tablelength(frame:getParent().args) == 0 
	then
		return frame:expandTemplate{title= 'sw-conj/table-pres-prn', args = {}}
	end
	
	local args = frame:getParent().args or {}
	
	local lemma = args or PAGENAME
	local stem, arabic, monosyllabic, cat = get_stem(lemma, args)
	
	return frame:expandTemplate{
		title= 'sw-conj/table-pres-prn',
		args = make_forms(args, lemma, stem, arabic, monosyllabic)
		} .. m_utils.format_categories(cat, lang)
end

function export.show_pres_pn(frame)
	if
		mw.title.getCurrentTitle().nsText == "Template" and
		tablelength(frame:getParent().args) == 0 
	then
		return frame:expandTemplate{title= 'sw-conj/table-pres-pn', args = {}}
	end
	
	local args = frame:getParent().args or {}
	
	local lemma = args or PAGENAME
	local stem, arabic, monosyllabic, cat = get_stem(lemma, args)
	
	return frame:expandTemplate{
		title= 'sw-conj/table-pres-pn',
		args = make_forms(args, lemma, stem, arabic, monosyllabic)
		} .. m_utils.format_categories(cat, lang)
end

function export.show_pres_p(frame)
	if
		mw.title.getCurrentTitle().nsText == "Template" and
		tablelength(frame:getParent().args) == 0 
	then
		return frame:expandTemplate{title= 'sw-conj/table-pres-p', args = {}}
	end
	
	local args = frame:getParent().args or {}
	
	local lemma = args or PAGENAME
	local stem, arabic, monosyllabic, cat = get_stem(lemma, args)
	
	return frame:expandTemplate{
		title= 'sw-conj/table-pres-p',
		args = make_forms(args, lemma, stem, arabic, monosyllabic)
		} .. m_utils.format_categories(cat, lang)
end

return export