Module:Pronoun: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Tag: Reverted
Line 1:
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",
-- Add more special cases as necessary
}
 
-- Determines if the stringcorrect isform fullyof "to be" based on the uppercasepronoun
local function isAllCapsformToBe(spronoun)
if pronoun:lower() == "he" or pronoun:lower() == "she" or pronoun:lower() == "it" then
return s:upper() == s
return end"is"
endelse
return end"are"
end
end
 
-- Capitalizes a word if the original was capitalized
-- Adjusts the verb based on the pronoun, verb tense, and input capitalization
local function matchCase(original, word)
if elseif verboriginal:sub(1,1):match("s$%u") then
return sword:sub(1,1):upper() ==.. sword:sub(2)
else
return endword
end
end
 
-- Adjusts the verb based on the pronoun, verbmaintaining tense, and inputspecific capitalization
local function adjustVerb(originalPronoun, originalVerb)
local pronoun = originalPronoun:lower() -- Use lowercase for logic
local verb = originalVerb:lower() -- Use lowercase for logic
local resultVerb = verb -- Default to the original verb form
 
local result = ""
-- Continuous tense (verbs ending in 'ing')
if verb:sub(-3) == "ing" then
local auxresultVerb = pronounformToBe(originalPronoun) ==.. "they" and "are" or.. "is"originalVerb
result = originalPronoun .. " " .. aux .. " " .. originalVerb
else
-- Simple present tense for singular third-personadjustments
if pronoun == "he" or pronoun == "she" or pronoun == "it" then
verbresultVerb = specialCases[verb] or (verb --.. Apply(verb:match("s$") specialand case"" ifor exists"s"))
elseif pronoun == "they" ifand (verb:match("es$") notor verb:match("s$")) then
-- Adjusting for plural verb(typically =just verbremoving ..the (needsEsEnding(verb)'s', andbut "es"some orverbs "s"may be irregular)
resultVerb = specialCases[verb] =or verb:sub(1, -2)
end
elseif pronoun == "they" then
-- Adjusting back from special cases if needed
for base, conjugated in pairs(specialCases) do
if verb == conjugated then
verb = base
end
end
-- Remove 'es' or 's' if present
if verb:match("es$") then
verb = verb:sub(1, -3)
elseif verb:match("s$") then
verb = verb:sub(1, -2)
end
end
resultVerb = matchCase(originalVerb, resultVerb) -- Adjust the case based on the original input
result = originalPronoun .. " " .. verb
end
 
-- Adjust for mixed capitalization (Title Case)
if not isAllCaps(originalPronoun) then
result = result:gsub("(%a)([%w_']*)", function(first, rest) return first:upper()..rest:lower() end)
end
 
-- Adjust the result for all caps
if isAllCaps(originalPronoun) and isAllCaps(originalVerb) then
result = result:upper()
end
return resultoriginalPronoun .. " " .. resultVerb
end
 
Line 66 ⟶ 52:
local originalPronoun = frame.args[1]
local originalVerb = frame.args[2]
return adjustVerb(originalPronoun, originalVerb) -- Adjust and return the result
end