Module:mg-noun/data: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(22 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
local match = mw.ustring.match | local match = mw.ustring.match | ||
local PAGENAME = mw.title.getCurrentTitle().text | local PAGENAME = mw.title.getCurrentTitle().text | ||
local deacuter = {["á"] = "a", ["é"] = "e", ["í"] = "i", ["ó"] = "o", ["ú"] = "u"} | |||
local cs = "bcdhjlmnñpqrstxzvgzʧʎ" | |||
local data = {} | local data = {} | ||
Line 12: | Line 15: | ||
} | } | ||
setmetatable(data["o"], {__call = function(self, args, data) | setmetatable(data["o"], {__call = function(self, args, data) | ||
local stem = data.head; local | local stem = data.head; data.decl_type = "o"; local s1 = sub(stem, 1, -2); local inserted = s1 | ||
local pat = { | |||
{"ch", "ʧ"}, {"il", "ʎ"}, | |||
table.insert(data.categories, "Modern Gallaecian o-declension nouns") | {"([^" .. cs .. "])([" .. cs .. "]*)(i?)$", "%1i%2%3"}, {"ii", "i"}, {"c$", "qu"}, {"ʎ", "il"}, {"ʧ", "ch"} | ||
} | |||
for _, repl in ipairs(pat) do | |||
inserted = gsub(inserted, repl[1], repl[2]) | |||
end | |||
table.insert(data.categories, "Modern Gallaecian o-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
data.forms["di_s"] = {s1 .. "o"} | data.forms["di_s"] = {s1 .. "o"} | ||
Line 34: | Line 44: | ||
} | } | ||
setmetatable(data["a"], {__call = function(self, args, data) | setmetatable(data["a"], {__call = function(self, args, data) | ||
local stem = data.head | local stem = data.head; data.decl_type = "a"; local s1 = sub(stem, 1, -2) | ||
table.insert(data.categories, "Modern Gallaecian a-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
table.insert(data.categories, "Modern Gallaecian a-declension nouns") | |||
data.forms["di_s"] = {s1 .. "a"} | data.forms["di_s"] = {s1 .. "a"} | ||
Line 56: | Line 64: | ||
} | } | ||
setmetatable(data["e"], {__call = function(self, args, data) | setmetatable(data["e"], {__call = function(self, args, data) | ||
local stem = data.head | local stem = data.head; data.decl_type = "e"; local s1 = sub(stem, 1, -2) | ||
table.insert(data.categories, "Modern Gallaecian e-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
table.insert(data.categories, "Modern Gallaecian e-declension nouns") | |||
data.forms["di_s"] = {s1 .. "e"} | data.forms["di_s"] = {s1 .. "e"} | ||
Line 80: | Line 86: | ||
local stem = data.head; data.decl_type = "n" | local stem = data.head; data.decl_type = "n" | ||
local s1 = sub(stem, 1, -2); local s2 = sub(stem, 1, -3) | local s1 = sub(stem, 1, -2); local s2 = sub(stem, 1, -3) | ||
local changes = {["d"] = "n", ["z"] = "i", [" | local changes = {["d"] = "n", ["z"] = "i", ["ñ"] = "n"} | ||
local changed = gsub(s1, ".$", function(foo) return changes[foo] or "-" end) | local changed = gsub(s1, ".$", function(foo) return changes[foo] or "-" end) | ||
table.insert(data.categories, "Modern Gallaecian n-declension nouns") | table.insert(data.categories, "Modern Gallaecian n-declension " .. (data.proper and "proper" or "") .. " nouns") | ||
data.forms["di_s"] = {stem} | data.forms["di_s"] = {stem} | ||
Line 88: | Line 94: | ||
if not match(changed, "-") then | if not match(changed, "-") then | ||
data.forms["da_s"] = { | data.forms["da_s"] = {changed .. "ne"} | ||
data.forms["lo_s"] = { | data.forms["lo_s"] = {changed .. "ne"} | ||
data.forms["da_p"] = { | data.forms["da_p"] = {changed .. "nú"} | ||
data.forms["lo_p"] = { | data.forms["lo_p"] = {changed .. "nui"} | ||
end | end | ||
Line 103: | Line 109: | ||
} | } | ||
setmetatable(data["r"], {__call = function(self, args, data) | setmetatable(data["r"], {__call = function(self, args, data) | ||
local stem = data.head | local stem = data.head; data.decl_type = "r" | ||
local s1 = sub(stem, 1, -2); local s2 = sub(stem, 1, -3) | local s1 = sub(stem, 1, -2); local s2 = sub(stem, 1, -3) | ||
table.insert(data.categories, "Modern Gallaecian r-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
table.insert(data.categories, "Modern Gallaecian r-declension nouns") | |||
data.forms["di_s"] = {s1 .. "r"} | data.forms["di_s"] = {s1 .. "r"} | ||
Line 115: | Line 120: | ||
data.forms["da_p"] = {s2 .. "rú"} | data.forms["da_p"] = {s2 .. "rú"} | ||
data.forms["lo_p"] = {s2 .. "rui"} | data.forms["lo_p"] = {s2 .. "rui"} | ||
end | |||
}) | |||
data["nt"] = { | |||
params = { | |||
[1] = {}, | |||
}, | |||
} | |||
setmetatable(data["nt"], {__call = function(self, args, data) | |||
local stem = data.head; data.decl_type = "nt"; local s1 = sub(stem, 1, -3) .. (deacuter[sub(stem, -2, -2)] or sub(stem, -2, -2)) | |||
table.insert(data.categories, "Modern Gallaecian nt-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
data.forms["di_s"] = {stem} | |||
data.forms["da_s"] = {s1 .. "nze"} | |||
data.forms["lo_s"] = {s1 .. "nze"} | |||
data.forms["di_p"] = {s1 .. "ndes"} | |||
data.forms["da_p"] = {s1 .. "ndú"} | |||
data.forms["lo_p"] = {s1 .. "ndui"} | |||
end | |||
}) | |||
data["á"] = { | |||
params = { | |||
[1] = {}, | |||
}, | |||
} | |||
setmetatable(data["á"], {__call = function(self, args, data) | |||
local stem = data.head; data.decl_type = "á"; local s1 = sub(stem, 1, -2) | |||
table.insert(data.categories, "Modern Gallaecian á-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
data.forms["di_s"] = {s1 .. "á"} | |||
data.forms["da_s"] = {s1 .. "á"} | |||
data.forms["lo_s"] = {s1 .. "aie"} | |||
data.forms["di_p"] = {s1 .. "ás"} | |||
data.forms["da_p"] = {s1 .. "ahú"} | |||
data.forms["lo_p"] = {s1 .. "ahui"} | |||
end | |||
}) | |||
data["cons"] = { | |||
params = { | |||
[1] = {}, | |||
}, | |||
} | |||
setmetatable(data["cons"], {__call = function(self, args, data) | |||
local stem = data.head; data.decl_type = "consonant" | |||
local qstem = sub(stem, -1) == "c" and gsub(stem, "c$", "qu") or stem | |||
table.insert(data.categories, "Modern Gallaecian consonant-declension " .. (data.proper and "proper" or "") .. " nouns") | |||
data.forms["di_s"] = {stem} | |||
data.forms["da_s"] = {qstem .. "e"} | |||
data.forms["lo_s"] = {qstem .. "e"} | |||
data.forms["di_p"] = {qstem .. "es"} | |||
data.forms["da_p"] = {stem .. "ú"} | |||
data.forms["lo_p"] = {stem .. "ui"} | |||
end | end |
Latest revision as of 20:01, 29 January 2022
- The following documentation is located at Module:mg-noun/data/doc.[edit]
- Useful links: root page • root page's subpages • links • transclusions • testcases • sandbox
local sub = mw.ustring.sub
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local PAGENAME = mw.title.getCurrentTitle().text
local deacuter = {["á"] = "a", ["é"] = "e", ["í"] = "i", ["ó"] = "o", ["ú"] = "u"}
local cs = "bcdhjlmnñpqrstxzvgzʧʎ"
local data = {}
data["o"] = {
params = {
[1] = {},
},
}
setmetatable(data["o"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "o"; local s1 = sub(stem, 1, -2); local inserted = s1
local pat = {
{"ch", "ʧ"}, {"il", "ʎ"},
{"([^" .. cs .. "])([" .. cs .. "]*)(i?)$", "%1i%2%3"}, {"ii", "i"}, {"c$", "qu"}, {"ʎ", "il"}, {"ʧ", "ch"}
}
for _, repl in ipairs(pat) do
inserted = gsub(inserted, repl[1], repl[2])
end
table.insert(data.categories, "Modern Gallaecian o-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {s1 .. "o"}
data.forms["da_s"] = {s1 .. "o"}
data.forms["lo_s"] = {inserted .. "e"}
data.forms["di_p"] = {s1 .. "os"}
data.forms["da_p"] = {s1 .. "ú"}
data.forms["lo_p"] = {s1 .. "ui"}
end
})
data["a"] = {
params = {
[1] = {},
},
}
setmetatable(data["a"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "a"; local s1 = sub(stem, 1, -2)
table.insert(data.categories, "Modern Gallaecian a-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {s1 .. "a"}
data.forms["da_s"] = {s1 .. "e"}
data.forms["lo_s"] = {s1 .. "e"}
data.forms["di_p"] = {s1 .. "as"}
data.forms["da_p"] = {s1 .. "au"}
data.forms["lo_p"] = {s1 .. "ai"}
end
})
data["e"] = {
params = {
[1] = {},
},
}
setmetatable(data["e"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "e"; local s1 = sub(stem, 1, -2)
table.insert(data.categories, "Modern Gallaecian e-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {s1 .. "e"}
data.forms["da_s"] = {s1 .. "e"}
data.forms["lo_s"] = {s1 .. "e"}
data.forms["di_p"] = {s1 .. "es"}
data.forms["da_p"] = {s1 .. "iu"}
data.forms["lo_p"] = {s1 .. "ei"}
end
})
data["n"] = {
params = {
[1] = {},
},
}
setmetatable(data["n"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "n"
local s1 = sub(stem, 1, -2); local s2 = sub(stem, 1, -3)
local changes = {["d"] = "n", ["z"] = "i", ["ñ"] = "n"}
local changed = gsub(s1, ".$", function(foo) return changes[foo] or "-" end)
table.insert(data.categories, "Modern Gallaecian n-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {stem}
data.forms["di_p"] = {s2 .. "nes"}
if not match(changed, "-") then
data.forms["da_s"] = {changed .. "ne"}
data.forms["lo_s"] = {changed .. "ne"}
data.forms["da_p"] = {changed .. "nú"}
data.forms["lo_p"] = {changed .. "nui"}
end
end
})
data["r"] = {
params = {
[1] = {},
},
}
setmetatable(data["r"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "r"
local s1 = sub(stem, 1, -2); local s2 = sub(stem, 1, -3)
table.insert(data.categories, "Modern Gallaecian r-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {s1 .. "r"}
data.forms["da_s"] = {s2 .. "re"}
data.forms["lo_s"] = {s2 .. "re"}
data.forms["di_p"] = {s2 .. "res"}
data.forms["da_p"] = {s2 .. "rú"}
data.forms["lo_p"] = {s2 .. "rui"}
end
})
data["nt"] = {
params = {
[1] = {},
},
}
setmetatable(data["nt"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "nt"; local s1 = sub(stem, 1, -3) .. (deacuter[sub(stem, -2, -2)] or sub(stem, -2, -2))
table.insert(data.categories, "Modern Gallaecian nt-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {stem}
data.forms["da_s"] = {s1 .. "nze"}
data.forms["lo_s"] = {s1 .. "nze"}
data.forms["di_p"] = {s1 .. "ndes"}
data.forms["da_p"] = {s1 .. "ndú"}
data.forms["lo_p"] = {s1 .. "ndui"}
end
})
data["á"] = {
params = {
[1] = {},
},
}
setmetatable(data["á"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "á"; local s1 = sub(stem, 1, -2)
table.insert(data.categories, "Modern Gallaecian á-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {s1 .. "á"}
data.forms["da_s"] = {s1 .. "á"}
data.forms["lo_s"] = {s1 .. "aie"}
data.forms["di_p"] = {s1 .. "ás"}
data.forms["da_p"] = {s1 .. "ahú"}
data.forms["lo_p"] = {s1 .. "ahui"}
end
})
data["cons"] = {
params = {
[1] = {},
},
}
setmetatable(data["cons"], {__call = function(self, args, data)
local stem = data.head; data.decl_type = "consonant"
local qstem = sub(stem, -1) == "c" and gsub(stem, "c$", "qu") or stem
table.insert(data.categories, "Modern Gallaecian consonant-declension " .. (data.proper and "proper" or "") .. " nouns")
data.forms["di_s"] = {stem}
data.forms["da_s"] = {qstem .. "e"}
data.forms["lo_s"] = {qstem .. "e"}
data.forms["di_p"] = {qstem .. "es"}
data.forms["da_p"] = {stem .. "ú"}
data.forms["lo_p"] = {stem .. "ui"}
end
})
return data