45,342
edits
No edit summary |
No edit summary |
||
(42 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
local gsub = mw.ustring.gsub | local gsub = mw.ustring.gsub | ||
local sub = mw.ustring.sub | local sub = mw.ustring.sub | ||
local split = mw.text.split | |||
local TILDEB = u(0x0330) -- COMBINING TILDE BELOW ̰◌ | local TILDEB = u(0x0330) -- COMBINING TILDE BELOW ̰◌ | ||
Line 16: | Line 17: | ||
end | end | ||
local function plural(word) | local function plural(word, n, pos) | ||
local | local w = split(word, " ") | ||
n = tonumber(n) | |||
if n > #w then error("Word index outside bounds.") end | |||
if | if pos == "n" then | ||
if w[n]:match("[kh]wa$") then | |||
w[n] = sub(w[n], 1, -3) .. "úr" | |||
elseif w[n]:match("a$") then | |||
w[n] = sub(w[n], 1, -2) .. "úr" | |||
elseif w[n]:match("ës$") or w[n]:match("uin$") or w[n]:match("[str]$") then | |||
w[n] = w[n] .. "á" | |||
elseif w[n]:match("[nml]$") then | |||
w[n] = w[n] .. "ur" | |||
end | |||
elseif pos == "adj" then | |||
if w[n]:match("[kh]win$") then | |||
w[n] = sub(w[n], 1, -4) .. "ú" | |||
elseif w[n]:match("in$") then | |||
w[n] = sub(w[n], 1, -3) .. "u" | |||
end | |||
end | end | ||
return {label = "plural", table.concat(w, " ")} | |||
end | end | ||
Line 37: | Line 49: | ||
["pl"] = {list = true}, | ["pl"] = {list = true}, | ||
["w"] = {default = mw.title.getCurrentTitle().text}, | ["w"] = {default = mw.title.getCurrentTitle().text}, | ||
["n"] = {type = number, default = 1} | |||
} | } | ||
local args = require("Module:parameters").process(frame:getParent().args, params) | local args = require("Module:parameters").process(frame:getParent().args, params) | ||
local word = args | local word = args.w | ||
local pos = args[1]; local pl = args | local pos = args[1]; local pl = args.pl | ||
local data = {lang = lang, pos_category = deabb[pos], heads = {word}, categories = {}, inflections = {},} | local data = {lang = lang, pos_category = deabb[pos], heads = {word}, categories = {}, inflections = {},} | ||
if pl[1] == '-' then | if pl[1] == '-' then | ||
Line 53: | Line 67: | ||
if pos == "adv" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. deabb[pos]) end ]=] | if pos == "adv" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. deabb[pos]) end ]=] | ||
else | else | ||
if pl then | if pl[1] then | ||
pl.label = "plural" | pl.label = "plural" | ||
table.insert(data.inflections, pl) | table.insert(data.inflections, pl) | ||
else | else | ||
table.insert(data.inflections, plural(word)) | table.insert(data.inflections, plural(word, args.n, pos)) | ||
end | end | ||
end | end |