Module:Pronoun

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 19:15, 18 March 2024 by Vish (talk | contribs)
Jump to navigation Jump to search

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

local p = {}

-- Normalizes the input to ensure consistent processing
local function normalizeInput(input)
    if not input then return "" end
    return input:lower()
end

-- Adjusts the verb based on the pronoun and the verb tense
local function adjustVerb(pronoun, verb)
    pronoun = normalizeInput(pronoun) -- Normalize the pronoun to handle case sensitivity
    -- Handle continuous tense (verbs ending in 'ing')
    if verb:sub(-3) == "ing" then
        if pronoun == "he" or pronoun == "she" or pronoun == "it" then
            return pronoun .. " is " .. verb
        elseif pronoun == "they" then
            return pronoun .. " are " .. verb
        end
    else
        -- Handle simple present tense for singular third-person
        if pronoun == "he" or pronoun == "she" or pronoun == "it" then
            -- Special case for 'go' -> 'goes'; expand as needed for other irregular verbs
            if verb == "go" then
                verb = "goes"
            elseif not verb:match("s$") then -- Add 's' if it doesn't already end with one
                verb = verb .. "s"
            end
        elseif pronoun == "they" and verb:match("es$") then
            verb = verb:sub(1, -3) -- Remove 'es' for verbs that end in 'es', like 'goes' -> 'go'
        elseif pronoun == "they" and verb:match("s$") then
            verb = verb:sub(1, -2) -- Remove 's' for regular verbs
        end
        return pronoun .. " " .. verb
    end
end

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

return p