Module:Grammar: Difference between revisions

210 bytes removed ,  20:38, 10 September 2019
half of a migration away from cargo
No edit summary
(half of a migration away from cargo)
Line 1: Line 1:
local p = {}
local p = {}
local pronouns = require'Module:Grammar/PronounsTable'
local genders = require'Module:Grammar/GenderTable'
local cargo = mw.ext.cargo
local cargo = mw.ext.cargo


--[TODO: do something about oboroqoru's He/Him/His/His/Himself/god/godling/lord/Son/Brother]--/Father pronouns]
function p.Main(frame)
function p.Main(frame)


Line 9: Line 13:
   pronoun = frame.args[3]
   pronoun = frame.args[3]
else  
else  
   pronounresult = cargo.query('Genders','defaultpronouns',{where='Gender="' .. gender .. '" AND _pageName="Gender and Pronouns"',limit='1'})
   pronounresult = genders[gender]['defaultpronouns']
   if not next(pronounresult) then
   if (pronounresult == nil) then
       return "can't find a pronoun!"
       error ("can't find a pronoun for gender" .. (gender or "(no gender)") .. "!")
   else  
   else  
       pronoun = pronounresult[1]['defaultpronouns']
       pronoun = pronounresult
   end
   end
end
end
Line 101: Line 105:
      
      
     fields = field
     fields = field
   
     if (string.find(field, "term", -4) ~= nil) then
     if (string.find(field, "term", -4) ~= nil) then
     table = 'Genders'
     table = 'Genders'
Line 120: Line 126:


function p.isplural(gender,pronoun)
function p.isplural(gender,pronoun)
    fields= "pseudoplural"
     local result = pronouns[pronoun]['pseudoplural']
    args = {
     local resulttwo = genders[gender]['plural']
        where='pronoun="' .. pronoun .. '" AND _pageName="Gender and Pronouns"',
 
        limit='1'
     if (result == nil) then
    }
         return resulttwo or nil
     local result= cargo.query('Pronouns',fields,args)
     local resulttwo= cargo.query('Genders','plural',{where='Gender="'..gender..'" AND _pageName="Gender and Pronouns"',
        limit='1'})
     if not next(result) then
         if not next(resulttwo) then
            return nil
        else
            return resulttwo[1]['plural']
        end
     else
     else
         if not next(resulttwo) then
         if (resulttwo == nil) then
           return result[1]['pseudoplural']
           return result[1]['pseudoplural']
         else  
         else  
           if (result[1]['pseudoplural'] == '1' or resulttwo[1]['plural'] == '1') then
           if (result == 1 or resulttwo == 1) then
    return '1'
    return '1'
           else
           else