Module:Grammar: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 58: | Line 58: | ||
end | end | ||
else | else | ||
local results = parse(b, gender, pronoun) | local results = p.parse(b, gender, pronoun) | ||
if results == nil then | if results == nil then | ||
returnstring = "No results!" | returnstring = "No results!" | ||
Line 81: | Line 81: | ||
else | else | ||
local results = isplural(gender,pronoun) | local results = p.isplural(gender,pronoun) | ||
if (results == '0') then | if (results == '0') then | ||
Line 115: | Line 115: | ||
end | end | ||
function p.parse(field, gender, pronoun) | |||
return progentable[field] | return progentable[field] | ||
end | end | ||
function p.isplural(gender,pronoun) | |||
if progentable["pseudoplural"] == '1' or progentable["plural"] == '1' then | if progentable["pseudoplural"] == '1' or progentable["plural"] == '1' then | ||
return '1' | return '1' | ||
Line 127: | Line 127: | ||
end | end | ||
function p.test() | |||
text="You stand not at the foot of a wintry knoll but beneath a mountain of muscle, swathed in blanched fur, that must be nature's crowning jewel. Cast from the mold of the great apes (or perhaps the exemplar from which those apes were molded), the living god differs only in that =pronouns.subjective= =verb:bear:afterpronoun= not two but six arms, each of which might be the fleeced bole of an ancient yew. =pronouns.Possessive= fists are of proportions that suggest the might with which hoary gods beat the mountains into shape when the earth was young. However, =pronouns.possessive= aspect bears not a shred of that divine fury; =pronouns.subjective= =verb:don't:afterpronoun= rage but instead =verb:sit:afterpronoun= in contemplation of eons." | |||
local | gender = "male" | ||
pronoun = "he/him/his/his/himself/god/godling/lord/son/brother/father" | |||
local f = {["args"] = {[1]= text, [2] = gender, [3] = pronoun }} | |||
return p.Main(f) | |||
end | end | ||
return p | return p |
Revision as of 17:54, 12 September 2019
local p = {}
local pronouns = require'Module:Grammar/PronounsTable'
local genders = require'Module:Grammar/GenderTable'
local progentable = {}
function p.Main(frame)
gender = frame.args[2]
if (frame.args[3] ~= nil and frame.args[3] ~= '') then
pronoun = frame.args[3]
else
pronounresult = genders[gender]['defaultpronouns']
if (pronounresult == nil) then
error ("can't find a pronoun for gender" .. (gender or "(no gender)") .. "!")
else
pronoun = pronounresult
end
end
progentable = {
["subjective"] = pronouns[pronoun]["subjective"],
["objective"] = pronouns[pronoun]["objective"],
["possessive"] = pronouns[pronoun]["possessive"],
["substantivepossessive"] = pronouns[pronoun]["substantivepossessive"],
["reflexive"] = pronouns[pronoun]["reflexive"],
["pseudoplural"] = pronouns[pronoun]["pseudoplural"],
["plural"] = pronouns[pronoun]["plural"] or genders[gender]["plural"],
["personterm"] = pronouns[pronoun]["personterm"] or genders[gender]["personterm"],
["immaturepersonterm"] = pronouns[pronoun]["immaturepersonterm"] or genders[gender]["immaturepersonterm"],
["formaladdressterm"] = pronouns[pronoun]["formaladdressterm"] or genders[gender]["formaladdressterm"],
["offspringterm"] = pronouns[pronoun]["offspringterm"] or genders[gender]["offspringterm"],
["siblingterm"] = pronouns[pronoun]["siblingterm"] or genders[gender]["siblingterm"],
["parentterm"] = pronouns[pronoun]["parentterm"] or genders[gender]["parentterm"]
}
parsedtext = string.gsub(frame.args[1], "=([^=]+)=", function(f)
for a, b, c in string.gmatch(f, "(%w*)[:%.]?(['%w]*)(:?%w*)") do
if b == nil or b == "" then
if a == "article" then
return "a "
else
return "="..a.."="
end
else
local capitalized = ((b:gsub("^%l", string.upper)) == string.gsub(b,"(^%w)","%1"))
returnstring = ""
b = string.lower(b)
if (a == "name") then
returnstring = "(player's name)"
elseif (a == "player") then
returnstring = "(player's " .. b .. ")"
elseif (a == "pronouns") then
if (b == "indicativeproximal") then
if (p.isplural(gender,pronoun) == '0') then
returnstring = "this"
else
returnstring = "these"
end
else
local results = p.parse(b, gender, pronoun)
if results == nil then
returnstring = "No results!"
end
returnstring = results
end
elseif (a == "verb") then
if (c == nil or c == '') then
if (b == "are") then
returnstring= "is"
elseif (b == "have") then
returnstring= "has"
elseif (b == "'re") then
returnstring= "'s"
elseif (b =="don't") then
returnstring= "doesn't"
elseif (b== "'ve") then
returnstring="'s"
else
returnstring= b .. "s"
end
else
local results = p.isplural(gender,pronoun)
if (results == '0') then
if (b == "are") then
returnstring= "is"
elseif (b == "have") then
returnstring= "has"
elseif (b == "'re") then
returnstring= "'s"
elseif (b == "don't") then
returnstring= "doesn't"
elseif (b== "'ve") then
returnstring="'s"
else
returnstring= b .. "s"
end
else
returnstring= b
end
end
else
returnstring= f
end
if (capitalized == true) then
return (returnstring:gsub("^%l", string.upper))
else
return returnstring
end
end
end
end)
return parsedtext
end
function p.parse(field, gender, pronoun)
return progentable[field]
end
function p.isplural(gender,pronoun)
if progentable["pseudoplural"] == '1' or progentable["plural"] == '1' then
return '1'
else
return '0'
end
end
function p.test()
text="You stand not at the foot of a wintry knoll but beneath a mountain of muscle, swathed in blanched fur, that must be nature's crowning jewel. Cast from the mold of the great apes (or perhaps the exemplar from which those apes were molded), the living god differs only in that =pronouns.subjective= =verb:bear:afterpronoun= not two but six arms, each of which might be the fleeced bole of an ancient yew. =pronouns.Possessive= fists are of proportions that suggest the might with which hoary gods beat the mountains into shape when the earth was young. However, =pronouns.possessive= aspect bears not a shred of that divine fury; =pronouns.subjective= =verb:don't:afterpronoun= rage but instead =verb:sit:afterpronoun= in contemplation of eons."
gender = "male"
pronoun = "he/him/his/his/himself/god/godling/lord/son/brother/father"
local f = {["args"] = {[1]= text, [2] = gender, [3] = pronoun }}
return p.Main(f)
end
return p