Module:Grammar: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 15: Line 15:
     local pron = frame.args[2]
     local pron = frame.args[2]
     local results = p.isplural(pron)
     local results = p.isplural(pron)
    if not results then
return "No results!"
    end
     if (results[1][pron] == 0) then
     if (results[1][pron] == 0) then
       if (b == "are") then
       if (b == "are") then
           return "is"
           return "is"
      else
        return b .. "s"
       end
       end
    return b .. "s"
     else  
     else  
     return b
     return b
Line 31: Line 35:


function p.parse(field, pronoun)
function p.parse(field, pronoun)
     fields=field
     fields = 'possessive'
     args = {
     args = {
         where='pronoun="' .. pronoun .. '" AND _pageName="Gender and Pronouns"',
         where='pronoun="' .. pronoun .. '" AND _pageName="Gender and Pronouns"',

Revision as of 22:02, 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