Module:Pronoun: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 8:
-- Special cases for verb conjugation that don't follow the regular 's' or 'es' pattern
local specialCases = {
["go"] = "goes",
["do"] = "does"
}
 
Line 28 ⟶ 29:
local function adjustVerb(originalPronoun, originalVerb)
local pronoun = originalPronoun:lower() -- Use lowercase for logic
local verb = originalVerb and originalVerb:lower() or "" -- Use lowercase for logic, check for nil
 
local result = ""
-- ContinuousCheck tenseif (verbsa endingverb inis 'ing')provided
if verb:sub(-3) == "ing" then
-- No verb provided, return pronoun as is
result = applyContinuousVerb(originalPronoun, originalVerb)
result = originalPronoun .. " " .. verb
else
-- SimpleHandle presentverb tense for singular third-personlogic
if pronounverb:sub(-3) == "he" or pronoun == "she" or pronoun == "iting" then
result = applyContinuousVerb(originalPronoun, originalVerb)
verb = specialCases[verb] or verb -- Apply special case if exists
endelse
if not verb:match("s$") then
-- Simple present tense for singular third-person
verb = verb .. (needsEsEnding(verb) and "es" or "s")
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
end
elseif pronoun if verb == "theyhas" then
-- Adjusting back from special cases if needed verb = "has"
for base, conjugated in pairs(specialCases) doelse
if verb == conjugatedspecialCases[verb] or verb -- Apply special case if thenexists
verbif =not verb:match("s$") basethen
verb = verb .. (needsEsEnding(verb) and "es" or "s")
end
verb = verb:sub(1, -3)end
elseif verb:match(pronoun == "s$they") then
if verb:match( == "es$has") then
verb = verb:sub(1, -2)= "have"
else
verb = specialCases[verb] or verb -- Apply special case if exists
if not if verb:match("ses$") then
verb = verb:sub(1, -3)
elseif verb:match("s$") then
verb = verb:sub(1, -2)
end
end
end
--result Remove= 'es'originalPronoun or.. 's'" if" present.. verb
if verb:match("es$") then
verb = verb:sub(1, -3)
elseif verb:match("s$") then
verb = verb:sub(1, -2)
end
end
result = originalPronoun .. " " .. verb
end
 
-- Preserve the original case without converting everything to title case or uppercase, unless fully uppercase
if isAllCaps(originalPronoun) and isAllCaps(originalVerb) then
result = result:upper() -- Only convert to uppercase if both inputs were uppercase
end
end
 
Line 68 ⟶ 77:
function p.main(frame)
local originalPronoun = frame.args[1]
local originalVerb = frame.args[2] -- This can be nil or empty
return adjustVerb(originalPronoun, originalVerb) -- Adjust and return the result
end