Module:Pronoun: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
-- AdjustsChecks theif a verb basedneeds onan the'es' pronounending and(for thethird-person verbsingular simple present tense)
local function adjustVerbneedsEsEnding(pronoun, verb)
return verb:match("[oschx]$") or verb:match("sh$") or verb:match("ss$")
-- Handle continuous tense (verbs ending in 'ing')
end
if verb:sub(-3) == "ing" then
 
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
-- Special cases for verb conjugation that don't follow the regular 's' or 'es' pattern
return pronoun .. " is " .. verb
local specialCases = {
elseif pronoun == "they" then
verb["go"] = "goes",
return pronoun .. " are " .. verb
["do"] = end"does"
}
 
-- Determines if the string is fully uppercase
local function isAllCaps(s)
return s:upper() == s
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 pronoun .. " isare " .. verb
else
--return Handlepronoun simple.. present" tenseis for" singular.. third-personverb
end
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
end
-- Special case for 'go' -> 'goes'; expand as needed for other irregular verbs
 
if verb == "go" then
-- Adjusts the verb based on the pronoun, verb tense, and input capitalization
verb = "goes"
local function adjustVerb(originalPronoun, originalVerb)
-- Add 's' if it doesn't already end with one, excluding verbs ending in 'ing'
local pronoun = originalPronoun:lower() -- Use lowercase for logic
elseif not verb:match("s$") then
local verb = originalVerb and originalVerb:lower() or "" -- Use lowercase for logic, check for nil
verb = verb .. "s"
 
local result = ""
-- Check if a verb is provided
if verb == "" then
-- No verb provided, return pronoun ..as " are " .. verbis
result = originalPronoun
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 verb == "gohas" then
verb = verb ..= "shas"
verb = verb:sub(1, -3) else
verb = specialCases[verb] or verb -- Apply special case if exists
elseif if not verb:match("s$") then
verb = verb .. (needsEsEnding(verb) and "es" or "s")
end
verb = verb:sub(1, -2) end
elseif pronoun == "they" then
if verb == "has" then
verb = "have"
else
verb = specialCases[verb] or verb
elseif pronoun == "they" and if verb:match("es$") then
verb = verb:sub(1, -3)
elseif pronoun == "they" and elseif verb:match("s$") then
verb = verb:sub(1, -2)
end
end
end
-- Remove the 's' forresult 'they',= consideringoriginalPronoun special.. verbs" like" 'goes'.. -> 'go'verb
end
elseif pronoun == "they" and verb:match("es$") then
 
verb = verb:sub(1, -3)
-- Preserve the original case without converting everything to uppercase
elseif pronoun == "they" and verb:match("s$") then
if isAllCaps(originalPronoun) and isAllCaps(originalVerb) then
verb = verb:sub(1, -2)
result = result:upper() -- Only convert to uppercase if both inputs were uppercase
end
return pronoun .. " " .. verb
end
 
return result
end
 
function p.main(frame)
local pronounoriginalPronoun = frame.args[1]
local verboriginalVerb = frame.args[2] -- This can be nil or empty
return adjustVerb(pronounoriginalPronoun, verboriginalVerb) -- Adjust the verb based on the pronoun and return the result
end