Module:siwa-noun/data: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 96: Line 96:
-- TODO: add alternative forms with table.insert
-- TODO: add alternative forms with table.insert
for n, case in pairs(cases) do
for n, case in pairs(cases) do
if stem:match(v.."[pb].$") then
if stem:match(v.."n.$") then
table.insert(data.forms[case], s2 .. "nṡi" .. ce[n])
table.insert(data.forms[case], s2 .. "nṡi" .. ce[n])
end
end

Revision as of 22:41, 24 July 2021



local sub = mw.ustring.sub
local match = mw.ustring.match
local v = "([aeiouyůõảẻỉỏủỷę])"

local ine, ill, ela, ade, all, abl, loc
local cases = {"ine", "ill", "ela", "ade", "all", "abl"}
local ce = {"a", "ta", "ka", "ma", "bma", "ska"}

local function lenition(word)
	local lenition_patterns = {
	[v.."[vųbhḥg]"..v] = "%1%2", ["bb"] = "b", ["dd"] = "d", ["gg"] = "g", ["ɟ"] = "į", ["mm"] = "m", ["ll"] = "l", ["nn"] = "n",
	["rr"] = "r", ["bġ"] = "p", ["pr"] = "p", ["dġ"] = "t", ["tr"] = "t", ["ḍb"] = "p", ["ð"] = "hh",
	["ḍg"] = "k", ["bm"] = "m", ["dn"] = "n", ["kn"] = "ng", ["([lr])pp"] = "%1p", ["([lr])tt"] = "%1t", ["([lrms])kk"] = "%1k",
	["k([lvs])"] = "g%1", ["ps"] = "bs",  ["d[aou]"] = "l", ["ġ[aou]"] = "vv", ["[dġ][eůy]"] = "", ["[rġ]i"] = "ṡi",
	["di"] = "", ["ɲi"] = "ɟi", ["ħį"] = "ṡ", ["[ou]ų"] = "ů", ["ɬ"] = "l",
	}
	for regex, repl in ipairs(lenition_patterns) do
		word = mw.ustring.gsub(word, regex, repl)
	end
	
	--word = mw.ustring.gsub(word, v.."[vųbhḥg]"..v, "%1%2")
	
	return word
end

local data = {}

data["a"] = {
	params = {
		[1] = {},
	},
}
setmetatable(data["a"], {__call = function(self, args, data)
	local stem = data.head; local lenited = lenition(stem)
	local s2, s3 = sub(lenited, 1, -3), sub(lenited, 1, -4)
	table.insert(data.categories, "Siwa inanimate nouns")
	table.insert(data.categories, "Siwa a-declension nouns")
	
	data.forms["u"] = {stem}
	
	if stem:match(v.."mm.$") then
		data.forms["m"] = {s3 .. (data.q == "s" and "mġa" or data.q == "l" and "mka" or "kka")}
	elseif stem:match(v.."nn.$") then
		data.forms["m"] = {s3 .. (data.q == "s" and "nka" or "kka")}
	elseif stem:match(v.."vv.$") then
		data.forms["m"] = {s3 .. "gga"}
	elseif stem:match(v.."[lrs]k.$") then
		data.forms["m"] = {s2 .. "kka"}
	elseif stem:match(v.."m.$") then
		data.forms["m"] = {s2 .. (data.q == "s" and "mġa" or data.q == "l" and "mka" or "kka")}
	elseif stem:match(v.."n.$") then
		data.forms["m"] = {s2 .. (data.q == "s" and "nka" or "kka")}
	elseif stem:match(v.."[pb].$") then
		data.forms["m"] = {s2 .. (data.q == "s" and "pra" or "ḍga")}
	elseif stem:match(v.."[td].$") then
		data.forms["m"] = {s2 .. (data.q == "s" and "tra" or "rka")}
	elseif stem:match(v.."r.$") then
		data.forms["m"] = {s2 .. "hka"}
	elseif stem:match(v.."ṡṡ.$") then
		data.forms["m"] = {s2 .. "ka"}
	else
		data.forms["m"] = {stem .. "ka"}
	end
	
	if stem:match(v.."mm.$") then
		loc = s3 .. (data.q == "s" and "mṡi" or data.q == "l" and "mki" or "kki")
	elseif stem:match(v.."nn.$") then
		loc = s3 .. (data.q == "s" and "nki" or "kki")
	elseif stem:match(v.."ṡṡ.$") then
		loc = s2 .. "ki"
	elseif stem:match(v.."vv.$") then
		loc = s3 .. "ggi"
	elseif stem:match(v.."[lrs]k.$") then
		loc = s2 .. "kki"
	elseif stem:match(v.."m.$") then
		loc = s2 .. (data.q == "s" and "mṡi" or data.q == "l" and "mki" or "kki")
	elseif stem:match(v.."n.$") then
		loc = s2 .. (data.q == "s" and "nki" or "kki")
	elseif stem:match(v.."[pb].$") then
		loc = s2 .. (data.q == "s" and "pri" or "ḍgi")
	elseif stem:match(v.."[td].$") then
		loc = s2 .. (data.q == "s" and "tri" or "tṡi")
	elseif stem:match(v.."r.$") then
		loc = s2 .. "hki"
	else
		loc = stem .. "ki"
	end
	
	data.forms["ine"] = {(ine or loc) .. ce[1]}
	data.forms["ill"] = {(ill or loc) .. ce[2]}
	data.forms["ela"] = {(ela or loc) .. ce[3]}
	data.forms["ade"] = {(ade or loc) .. ce[4]}
	data.forms["all"] = {(all or loc) .. ce[5]}
	data.forms["abl"] = {(abl or loc) .. ce[6]}
	
	-- TODO: add alternative forms with table.insert
	for n, case in pairs(cases) do
		if stem:match(v.."n.$") then
			table.insert(data.forms[case], s2 .. "nṡi" .. ce[n])
		end
	end
end
})





return data