Module:Grammar: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 3: | Line 3: | ||
function p.Main(frame) | function p.Main(frame) | ||
for a, b in string.gmatch(frame.args[1], "=(%w*)[:.](%w*):?%w*=") do | for a, b in string.gmatch(frame.args[1], "=?(%w*)[:.](%w*):?%w*=?") do | ||
if (a == "player") then | if (a == "player") then | ||
return "(player's " .. b .. ")" | return "(player's " .. b .. ")" |
Revision as of 22:08, 30 July 2019
local p = {}
local cargo = mw.ext.cargo
function p.Main(frame)
for a, b in string.gmatch(frame.args[1], "=?(%w*)[:.](%w*):?%w*=?") do
if (a == "player") then
return "(player's " .. b .. ")"
elseif (a =="pronouns") then
local results = p.parse(b, frame.args[2])
if not results then
return "No results!"
end
return results[1][b]
elseif (a == "verb") then
local pron = frame.args[2]
local results = p.isplural(pron)
if not results then
return "No results!"
end
if (results[1][pron] == 0) then
if (b == "are") then
return "is"
else
return b .. "s"
end
else
return b
end
else
return "ERROR"
end
return "error"
end
end
function p.parse(field, pronoun)
fields = 'possessive'
args = {
where='pronoun="' .. pronoun .. '" AND _pageName="Gender and Pronouns"',
limit='1'
}
local result= cargo.query('Pronouns',fields,args)
if not next(result) then
return nil
else
return result
end
end
function p.isplural(pronoun)
fields=pseudoplural
args = {
where='pronoun="' .. pronoun .. '" AND _pageName="Gender and Pronouns"',
limit='1'
}
local result= cargo.query('Pronouns',fields,args)
if not next(result) then
return nil
else
return result
end
end
return p