Module:Pronoun

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 19:08, 18 March 2024 by Vish (talk | contribs) (Created page with "local p = {} -- A function to check if the verb ends in 's' and should change based on pronoun local function adjustVerb(pronoun, verb) if pronoun == "he" or pronoun == "she" or pronoun == "it" then -- Add 's' for singular third-person, if it doesn't already end with 's' if not verb:match("s$") then verb = verb .. "s" end elseif pronoun == "they" then -- Remove 's' for 'they', consider special cases like 'goes' -> 'go'...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Pronoun/doc

local p = {}

-- A function to check if the verb ends in 's' and should change based on pronoun
local function adjustVerb(pronoun, verb)
    if pronoun == "he" or pronoun == "she" or pronoun == "it" then
        -- Add 's' for singular third-person, if it doesn't already end with 's'
        if not verb:match("s$") then
            verb = verb .. "s"
        end
    elseif pronoun == "they" then
        -- Remove 's' for 'they', consider special cases like 'goes' -> 'go'
        if verb:match("es$") then
            -- Remove 'es' for verbs that end in 'es', like 'goes'
            verb = verb:sub(1, -3)
        elseif verb:match("s$") then
            -- Remove 's' for regular verbs
            verb = verb:sub(1, -2)
        end
    end
    return verb
end

function p.main(frame)
    local pronoun = frame.args[1]
    local verb = frame.args[2]
    verb = adjustVerb(pronoun, verb) -- Adjust the verb based on the pronoun

    return pronoun .. " " .. verb
end

return p