Module:Grammar/Conjugate: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local p = {} function p.pluralize(str, apostrophe) apostrophe = apostrophe or '' local irregularplurals = {} if (str:sub(-1) == 's') then return (str .. apostrophe)...") |
m (oops) |
||
Line 21: | Line 21: | ||
function p.singularverb(string) | function p.singularverb(string) | ||
--[ Assumes the input string is already a plural verb.] | |||
local irregularsingulars = { | local irregularsingulars = { | ||
["are"] = 'is', | ["are"] = 'is', | ||
Line 31: | Line 32: | ||
if result ~= nil and result ~= '' then | if result ~= nil and result ~= '' then | ||
return result | return result | ||
else | else | ||
return string | return string .. "s" | ||
end | end | ||
end | end | ||
return p | return p |
Revision as of 17:16, 1 October 2019
local p = {}
function p.pluralize(str, apostrophe)
apostrophe = apostrophe or ''
local irregularplurals = {}
if (str:sub(-1) == 's') then
return (str .. apostrophe) --return unmodified (ends with 's', like 'boots', so we shouldn't append another 's')
elseif (string.sub(str, -1) == 'y') and apostrophe == '' then
return (string.sub(str, 1, -2) .. 'ies')
elseif (str:sub(-1) == 'z' or str:sub(-2) == 'ch' or str:sub(-2) == 'sh' or str:sub(-1) == 'x') and apostrophe == '' then
return (str .. 'es')
else
return (str.. apostrophe .. 's')
end
end
function p.make_possessive(string)
return p.pluralize(string, "'")
end
function p.singularverb(string)
--[ Assumes the input string is already a plural verb.]
local irregularsingulars = {
["are"] = 'is',
["have"] = 'has',
["'re"] = "'s",
["don't"] = "doesn't",
["'ve"] = "'s"
}
local result = irregularsingulars[string]
if result ~= nil and result ~= '' then
return result
else
return string .. "s"
end
end
return p