Module:Pronoun: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
-- DeterminesChecks if a verb shouldneeds end inan 'es' insteadending of(for justthird-person 's'singular simple present tense)
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
 
-- 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 = {
local function adjustVerb(originalPronoun, verb)
["go"] = "goes",
local pronoun = originalPronoun:lower() -- Use a lowercase version for logic
["do"] = "does"
-- Handle continuous tense (verbs ending in 'ing')
}
if verb:sub(-3) == "ing" then
 
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
-- Determines if the string is fully uppercase
return originalPronoun .. " is " .. verb
local function isAllCaps(s)
elseif pronoun == "they" then
return originalPronoun .. " are "s:upper() ..== verbs
end
 
-- Correctly applies 'is' or 'are' for continuous verbs based on pronoun, retaining input case
local function applyContinuousVerb(pronoun, verb)
if pronoun:lower() == "they" then
return originalPronounpronoun .. " isare " .. verb
else
--return Handlepronoun simple.. present" tenseis for" singular.. third-personverb
end
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
end
if needsEsEnding(verb) then
 
verb = verb .. "es"
-- Adjusts the verb based on the pronoun and the, verb tense, preserving originaland pronouninput capitalization
elseif not verb:match("s$") then -- Add 's' if it doesn't already end with one
local function adjustVerb(originalPronoun, verboriginalVerb)
verb = verb .. "s"
local pronoun = originalPronoun:lower() -- Use a lowercase version for logic
local verb = originalVerb and originalVerb:lower() or "" -- Use lowercase for logic, check for nil
 
local result = ""
-- Check if a verb is provided
if verb == "" then
-- No verb provided, return pronoun as is
returnresult = originalPronoun .. " " .. verb
else
-- Handle verb logic
if verb:sub(-3) == "ing" then
result = applyContinuousVerb(originalPronoun, originalVerb)
else
-- Simple present tense for singular third-person
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
if needsEsEnding(verb) == "has" then
verb = verb ..= "eshas"
else
verb = specialCases[verb] or verb -- Apply special case if exists
if not verb:match("s$") then
verb = verb .. (needsEsEnding(verb) and "es" or "s")
end
end
elseif pronoun == "they" then
if verb == "has" then
verb = verb ..= "shave"
else
verb = specialCases[verb] or verb
if verb:match("es$") then
verb = verb:sub(1, -3)
elseif not verb:match("s$") then -- Add 's' if it doesn't already end with one
verb = verb:sub(1, -2)
end
end
end
elseif pronoun = result = "they"originalPronoun and.. (verb:match("es$ ") or.. verb:match("s$")) then
end
verb = verb:sub(1, verb:match("es$") and -3 or -2) -- Remove 'es' or 's' appropriately
 
-- Preserve the original case without converting everything to uppercase
if isAllCaps(originalPronoun) and isAllCaps(originalVerb) then
result = result:upper() -- Only convert to uppercase if both inputs were uppercase
end
return originalPronoun .. " " .. verb
end
 
return result
end
 
function p.main(frame)
local originalPronoun = frame.args[1]
local verboriginalVerb = frame.args[2] -- This can be nil or empty
return adjustVerb(originalPronoun, verboriginalVerb) -- Adjust the verb based on the pronoun and return the result
end