Module:siwa-noun/data: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 152: | Line 152: | ||
data.forms["m"] = {s1 .. "ue", s1 .. "obi"} | data.forms["m"] = {s1 .. "ue", s1 .. "obi"} | ||
loc = s1 .. "uei" | loc = s1 .. "uei" | ||
else | |||
data.forms["m"] = {s1 .. "ie"} | |||
loc = s1 .. "iei" | |||
end | |||
elseif stem:match("[uyů].$") then | |||
if stem:match(v.."mm.$") then | |||
data.forms["m"] = {s3 .. "mme"} | |||
loc = s3 .. "mme" | |||
elseif stem:match(v.."[mn].$") then | |||
data.forms["m"] = {s2 .. "mme"} | |||
loc = s2 .. "mme" | |||
elseif stem:match(v.."k.$") then | |||
data.forms["m"] = {s2 .. (data.q == "s" and "gme" or "hme")} | |||
loc = s2 .. (data.q == "s" and "gme" or "hme") | |||
else | |||
data.forms["m"] = {lenition(stem) .. "me"} | |||
loc = lenition(stem) .. "mei" | |||
end | end | ||
end | end |
Revision as of 14:35, 25 July 2021
- The following documentation is located at Module:siwa-noun/data/doc.[edit]
- Useful links: root page • root page's subpages • links • transclusions • testcases • sandbox
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 s2, s3 = sub(lenition(stem), 1, -3), sub(lenition(stem), 1, -4)
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")}
loc = s3 .. (data.q == "s" and "mṡi" or data.q == "l" and "mki" or "kki")
elseif stem:match(v.."nn.$") then
data.forms["m"] = {s3 .. (data.q == "s" and "nka" or "kka")}
loc = s3 .. (data.q == "s" and "nki" or "kki")
elseif stem:match(v.."vv.$") then
data.forms["m"] = {s3 .. "gga"}
loc = s3 .. "ggi"
elseif stem:match(v.."[lrs]k.$") then
data.forms["m"] = {s2 .. "kka"}
loc = s2 .. "kki"
elseif stem:match(v.."m.$") then
data.forms["m"] = {s2 .. (data.q == "s" and "mġa" or data.q == "l" and "mka" or "kka")}
loc = s2 .. (data.q == "s" and "mṡi" or data.q == "l" and "mki" or "kki")
elseif stem:match(v.."n.$") then
data.forms["m"] = {s2 .. (data.q == "s" and "nka" or "kka")}
loc = s2 .. (data.q == "s" and "nki" or "kki")
elseif stem:match(v.."[pb].$") then
data.forms["m"] = {s2 .. (data.q == "s" and "pra" or "ḍga")}
loc = s2 .. (data.q == "s" and "pri" or "ḍgi")
elseif stem:match(v.."[td].$") then
data.forms["m"] = {s2 .. (data.q == "s" and "tra" or "rka")}
loc = s2 .. (data.q == "s" and "tri" or "tṡi")
elseif stem:match(v.."r.$") then
data.forms["m"] = {s2 .. "hka"}
loc = s2 .. "hki"
elseif stem:match(v.."ṡṡ.$") then
data.forms["m"] = {s2 .. "ka"}
loc = s2 .. "ki"
else
data.forms["m"] = {stem .. "ka"}
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])
elseif stem:match(v.."[pb].$") and data.q == "s" then
table.insert(data.forms[case], s2 .. "pṡi" .. ce[n])
end
end
end
})
data["e"] = {
params = {
[1] = {},
},
}
setmetatable(data["e"], {__call = function(self, args, data)
local stem = data.head
local s1, s2, s3 = sub(lenition(stem), 1, -2), sub(lenition(stem), 1, -3), sub(lenition(stem), 1, -4)
table.insert(data.categories, "Siwa e-declension nouns")
data.forms["u"] = {stem}
if stem:match("[ae]$") then
if stem:match(v.."ts.$") then
data.forms["m"] = {s3 .. "tsġi"}
loc = s3 .. "tsġi"
elseif stem:match(v.."n.$") then
data.forms["m"] = {s2 .. "di"}
ill, ela, ade = s2 .. "h", s2 .. "h", s2 .. "h"
all, abl = s2 .. "i", s2 .. "i"
ine = s2 .. "di"
elseif stem:match(v.."b.$") then
data.forms["m"] = {s2 .. "pri", s2 .. "bġi"}
loc = s3 .. "pṡi"
elseif stem:match(v.."k.$") then
data.forms["m"] = {s2 .. "ġi"}
loc = s2 .. "ṡi"
elseif stem:match(v.."m.$") then
data.forms["m"] = {s2 .. "mmi"}
loc = s2 .. "mmi"
elseif stem:match(v.."v.$") then
data.forms["m"] = {s2 .. "rri"}
loc = s2 .. "rri"
elseif stem:match(v.."t.$") then
data.forms["m"] = {s2 .. "tri"}
loc = s2 .. "tri"
elseif stem:match(v.."s.$") then
data.forms["m"] = {s2 .. "sġi"}
loc = s2 .. "sġi"
elseif stem:match(v.."l.$") then
data.forms["m"] = {s2 .. "lli"}
loc = s2 .. "lli"
elseif stem:match(v.."[hġ].$") then
data.forms["m"] = {s2 .. "ġgi"}
loc = s2 .. "ġġi"
else
data.forms["m"] = {stem .. "ri"}
loc = stem .. "ri"
end
elseif stem:match("[io]$") then
if stem:match(v.."mm.$") then
data.forms["m"] = {s3 .. "mme"}
loc = s3 .. "mmei"
elseif stem:match(v.."[mpbvnrlkg].$") then
local stl = sub(stem, -2, -2)
stl = stl:gsub("p", "b"); stl = stl:gsub("k", "g")
data.forms["m"] = {s2 .. stl .. stl .. "e"}
loc = s2 .. stl .. stl .. "ei"
elseif stem:match("o$") then
data.forms["m"] = {s1 .. "ue", s1 .. "obi"}
loc = s1 .. "uei"
else
data.forms["m"] = {s1 .. "ie"}
loc = s1 .. "iei"
end
elseif stem:match("[uyů].$") then
if stem:match(v.."mm.$") then
data.forms["m"] = {s3 .. "mme"}
loc = s3 .. "mme"
elseif stem:match(v.."[mn].$") then
data.forms["m"] = {s2 .. "mme"}
loc = s2 .. "mme"
elseif stem:match(v.."k.$") then
data.forms["m"] = {s2 .. (data.q == "s" and "gme" or "hme")}
loc = s2 .. (data.q == "s" and "gme" or "hme")
else
data.forms["m"] = {lenition(stem) .. "me"}
loc = lenition(stem) .. "mei"
end
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.."[^t][^nbkmvslhġ][ae]$") then
table.insert(data.forms[case], s2 .. "h" .. ce[n])
elseif stem:match("[^mpbvnrlkg]o$") then
table.insert(data.forms[case], s1 .. "obi" .. ce[n])
end
end
end
})
return data