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'
-- Checks if a verb needs an 'es' ending (for third-person singular simple present tense)
local function needsEsEnding(verb)
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$")
return verb:match("[oschx]$") or verb:match("sh$") or verb:match("ss$")
end
end


-- Special cases for verb conjugation that don't follow the regular 's' or 'es' pattern
-- Adjusts the verb based on the pronoun and the verb tense, preserving original pronoun capitalization
local specialCases = {
go = "goes",
}

-- Adjusts the verb based on the pronoun, verb tense, and maintains original capitalization
local function adjustVerb(originalPronoun, verb)
local function adjustVerb(originalPronoun, verb)
local pronoun = originalPronoun:lower() -- Use a lowercase version for logic
local pronoun = originalPronoun:lower() -- Use lowercase for logic
local originalVerb = verb -- Preserve the original verb for later comparison
-- Handle continuous tense (verbs ending in 'ing')
verb = verb:lower() -- Use lowercase for logic

-- Continuous tense (verbs ending in 'ing')
if verb:sub(-3) == "ing" then
if verb:sub(-3) == "ing" then
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
return originalPronoun .. " is " .. verb
return originalPronoun .. " is " .. originalVerb
elseif pronoun == "they" then
elseif pronoun == "they" then
return originalPronoun .. " are " .. verb
return originalPronoun .. " are " .. originalVerb
end
end
else
else
-- Handle simple present tense for singular third-person
-- 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
verb = specialCases[verb] or verb -- Apply special case if exists
verb = verb .. "es"
if not verb:match("s$") then
if needsEsEnding(verb) then
elseif not verb:match("s$") then -- Add 's' if it doesn't already end with one
verb = verb .. "s"
verb = verb .. "es"
else
verb = verb .. "s"
end
end
elseif pronoun == "they" then
-- For 'they', ensure verb is in base form, adjusting special cases as needed
for base, conjugated in pairs(specialCases) do
if verb == conjugated then
verb = base -- revert special case to base form
end
end
-- Remove 'es' or 's' if present (from a previously conjugated form)
if verb:match("es$") then
verb = verb:sub(1, -3)
elseif verb:match("s$") then
verb = verb:sub(1, -2)
end
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
end
-- Recombine with original pronoun, using modified verb if it was changed
return originalPronoun .. " " .. verb
return originalPronoun .. " " .. (verb == originalVerb:lower() and originalVerb or verb)
end
end
end
end
Line 35: Line 57:
local originalPronoun = frame.args[1]
local originalPronoun = frame.args[1]
local verb = frame.args[2]
local verb = frame.args[2]
return adjustVerb(originalPronoun, verb) -- Adjust the verb based on the pronoun and return the result
return adjustVerb(originalPronoun, verb) -- Adjust and return result
end
end



Revision as of 19:20, 18 March 2024

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

local p = {}

-- Checks if a verb needs an 'es' ending (for third-person singular simple present tense)
local function needsEsEnding(verb)
    return verb:match("[oschx]$") or verb:match("sh$") or verb:match("ss$")
end

-- Special cases for verb conjugation that don't follow the regular 's' or 'es' pattern
local specialCases = {
    go = "goes",
}

-- Adjusts the verb based on the pronoun, verb tense, and maintains original capitalization
local function adjustVerb(originalPronoun, verb)
    local pronoun = originalPronoun:lower() -- Use lowercase for logic
    local originalVerb = verb -- Preserve the original verb for later comparison
    verb = verb:lower() -- Use lowercase for logic

    -- 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 " .. originalVerb
        elseif pronoun == "they" then
            return originalPronoun .. " are " .. originalVerb
        end
    else
        -- Simple present tense for singular third-person
        if pronoun == "he" or pronoun == "she" or pronoun == "it" then
            verb = specialCases[verb] or verb -- Apply special case if exists
            if not verb:match("s$") then
                if needsEsEnding(verb) then
                    verb = verb .. "es"
                else
                    verb = verb .. "s"
                end
            end
        elseif pronoun == "they" then
            -- For 'they', ensure verb is in base form, adjusting special cases as needed
            for base, conjugated in pairs(specialCases) do
                if verb == conjugated then
                    verb = base -- revert special case to base form
                end
            end
            -- Remove 'es' or 's' if present (from a previously conjugated form)
            if verb:match("es$") then
                verb = verb:sub(1, -3)
            elseif verb:match("s$") then
                verb = verb:sub(1, -2)
            end
        end
        -- Recombine with original pronoun, using modified verb if it was changed
        return originalPronoun .. " " .. (verb == originalVerb:lower() and originalVerb or verb)
    end
end

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

return p