Module:Pronoun: Difference between revisions

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}

-- Determines if a verb should end in 'es' instead of just 's'
local function needsEsEnding(verb)
-- Verbs ending in o, ch, sh, ss, or x get 'es' in the third person singular
return verb:match("[oschx]$") or verb:match("sh$") or verb:match("ss$")
end


-- Adjusts the verb based on the pronoun and the verb tense, preserving original pronoun capitalization
-- Adjusts the verb based on the pronoun and the verb tense, preserving original pronoun capitalization
Line 14: Line 20:
-- Handle simple present tense for singular third-person
-- Handle simple present tense for singular third-person
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
if needsEsEnding(verb) then
-- Special case for 'go' -> 'goes'; expand as needed for other irregular verbs
if verb == "go" then
verb = verb .. "es"
verb = "goes"
elseif not verb:match("s$") then -- Add 's' if it doesn't already end with one
elseif not verb:match("s$") then -- Add 's' if it doesn't already end with one
verb = verb .. "s"
verb = verb .. "s"
end
end
elseif pronoun == "they" and verb:match("es$") then
elseif pronoun == "they" and (verb:match("es$") or verb:match("s$")) then
verb = verb:sub(1, -3) -- Remove 'es' for verbs that end in 'es', like 'goes' -> 'go'
verb = verb:sub(1, verb:match("es$") and -3 or -2) -- Remove 'es' or 's' appropriately
elseif pronoun == "they" and verb:match("s$") then
verb = verb:sub(1, -2) -- Remove 's' for regular verbs
end
end
return originalPronoun .. " " .. verb
return originalPronoun .. " " .. verb

Revision as of 19:18, 18 March 2024

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

local p = {}

-- Determines if a verb should end in 'es' instead of just 's'
local function needsEsEnding(verb)
    -- Verbs ending in o, ch, sh, ss, or x get 'es' in the third person singular
    return verb:match("[oschx]$") or verb:match("sh$") or verb:match("ss$")
end

-- Adjusts the verb based on the pronoun and the verb tense, preserving original pronoun capitalization
local function adjustVerb(originalPronoun, verb)
    local pronoun = originalPronoun:lower() -- Use a lowercase version for logic
    -- Handle continuous tense (verbs ending in 'ing')
    if verb:sub(-3) == "ing" then
        if pronoun == "he" or pronoun == "she" or pronoun == "it" then
            return originalPronoun .. " is " .. verb
        elseif pronoun == "they" then
            return originalPronoun .. " are " .. verb
        end
    else
        -- Handle simple present tense for singular third-person
        if pronoun == "he" or pronoun == "she" or pronoun == "it" then
            if needsEsEnding(verb) then
                verb = verb .. "es"
            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$") or verb:match("s$")) then
            verb = verb:sub(1, verb:match("es$") and -3 or -2) -- Remove 'es' or 's' appropriately
        end
        return originalPronoun .. " " .. verb
    end
end

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

return p