Module:Grammar
Jump to navigation
Jump to search
local p = {}
local cargo = mw.ext.cargo
function p.Main(frame)
for a, b in string.gmatch(frame.args[1], "(%w*)[:.](%w*)") do
if (a == "player") then
return "(player's " .. b
elseif (a =="pronouns") then
local results = p.parse(b, frame.args[2])
local formatted = p.formatResult(results)
local returned = replace
for _, row in ipairs(formatted) do
for x, y in ipairs(row) do
returned = y
end
end
return returned
elseif (a =="verb") then
return "todo"
else
return "ERROR"
end
return "error"
end
end
function p.parse(field, pronoun)
tables='Pronouns'
fields=field
args = {
where='pronoun=\"' .. pronoun .. '\" AND _pageName=\"Gender and Pronouns\"',
limit='1'
}
return cargo.query(tables,fields,args)
end
function p.formatResult(result)
local formatted = {}
-- this loop structure is pretty much always how you will process cargo data.
-- you will loop over the ipairs iterator of the results table and apply a bunch of processing to the row, and save it.
-- once it's been processed you will then print it.
for k, row in ipairs(result) do
formatted[k] = row
end
return formatted
end
return p