Module:UserPronouns
Documentation for this module may be created at Module:UserPronouns/doc
--[[
This module provides a way to retrieve pronouns for reffering to a specified
wiki user. Templates like Template:YourPronouns and Template:UserpagePronouns
provide a simple means to invoke this module.
]]
local p = {}
--[[
These variables hold various common pronoun sets for easy use. If you use a
common pronoun set and it's not already listed here, you can add it here so more
people can easily use it in the future.
Pronoun sets are structured as arrays of different forms. The first is the
subject pronoun, followed by the object pronoun, possessive determiner,
possessive pronoun, and reflexive form. The last two forms are contractions with
is/are and has/have. These do not need to be added if the forms end in "'s", as
if they are not listed, they will be generated automatically when used. The
contracted forms only need to be listed when they end in something other than
"'s".
]]
local p_name = {"","","'s","'s","'s self"," is"," has"}
local p_thisperson = {"this person","this person","this person's","this person's","this person's self","this person is","this person has"}
local p_they = {"they","them","their","theirs","themself","they're","they've"}
local p_she = {"she","her","her","hers","herself"}
local p_he = {"he","him","his","his","himself"}
local p_it = {"it","it","its","'s","itself"} -- English doesn't normally use a possessive pronoun for it/its, so the username is used instead for that particular case.
local p_fae = {"fae","faer", "faer","faers","faerself","fae're","fae've"}
local p_i = {"I","me","my","mine","myself","I'm","I've"}
--[[
This table consists of user pronouns. If you would like to add your pronouns to
this module, this is where you'll want to add them.
To add yourself, add a line below the last person in the list and paste the
following:
[""] = {},
Add your wiki username between the quotes, and add your pronouns between the
curly braces. List each set separated by a comma; if the set is already listed
in the variables above, you can simply reference it by typing its name. If it's
not one of the preset pronoun sets, you can either add it to the presets, or
put the list of forms directly in your personal pronoun set list.
Which one you choose will depend on how common the pronoun set is and whether
you think it's likely that other people on the wiki will also use those
pronouns.
If you list multiple pronouns, the module will pick randomly between them when
invoked. If used correctly, pages using user pronoun templates should display
the same pronoun within a sentance, and they may vary between sentances.
If you would like to have one pronoun set be more likely to show up in random
selection, you can simply add more copies of that set to your list so it has a
higher chance of being selected.
If you only use one pronoun set, you can simply put that one set in your list
and nothing else. It is not necesarry to include multiple copies of pronouns in
this case.
]]
local pronouns = {
["Coppersalts"] = {p_she, p_they},
["Timvideo326"] = {p_they, p_they, {"xe","xem","xyr","xyr","xemself"}},
["Arllyhautegoth"] = {p_she, p_fae},
["Gsn1vy"] = {p_she, p_she, p_she, p_they},
["FuzzyEpic3"] = {p_she, p_she, p_she, p_she, p_she, p_she, p_she, p_she, p_she, p_she, p_she},
["SGuySMW"] = {p_he, p_he, p_he},
["Jurta"] = {p_he, p_they},
["Satomi"] = {p_she, {"g","gr","gr","grs","grself"}, {"She","Her","Her","Hers","Herself"}},
["Alphermebo"] = {p_he, p_he, p_they},
["Ndnprct3"] = {p_he},
["BobTheTacocat"] = {p_they},
["Viviancherry"] = {p_she, p_he, p_they},
["CandiedCoder"] = {p_she},
["MeanContestantPlaceholder"] = {p_he},
["Jocobo"] = {p_he},
}
--[[
This table consists of the codes used for the different forms. The numbers are
their indicies in pronoun sets.
]]
local form_codes = {
["subject"] = 1,
["s"] = 1,
["nominative"] = 1,
["n"] = 1,
["they"] = 1,
["object"] = 2,
["o"] = 2,
["accusative"] = 2,
["a"] = 2,
["them"] = 2,
["possessive determiner"] = 3,
["pd"] = 3,
["their"] = 3,
["possessive pronoun"] = 4,
["pp"] = 4,
["theirs"] = 4,
["reflexive"] = 5,
["r"] = 5,
["intensive"] = 5,
["i"] = 5,
["themself"] = 5,
["present tense contraction"] = 6,
["prtc"] = 6,
["they're"] = 6,
["past tense contraction"] = 7,
["pstc"] = 7,
["they've"] = 7
}
--[[
This function retrieves the pronoun set for the given user.
It is placed in its own fuction so it can be reused across multiple functions.
]]
local function select_pronoun_set( user, seed )
pronoun_options = pronouns[user] -- selects the specified user from the pronouns table
single_set = {} -- initialize variable for holding the selected set
if pronoun_options == nil then
-- if they're not in the table, use their name
single_set = p_name
elseif #pronoun_options == 1 then
-- if they only have one set, select it
single_set = pronoun_options[1]
else
-- otherwise, select a random set from their list
-- set random seed
if seed == nil then
math.randomseed(os.time())
else
math.randomseed(os.time() + tonumber(seed))
end
single_set = pronoun_options[math.floor(math.random() * #pronoun_options + 1)]
end
return single_set
end
--[[
args[1] is the user
args[2] is the pronoun form
args[3] is the random seed offset
]]
function p.get_pronoun( frame )
single_set = select_pronoun_set(frame.args[1], frame.args[3])
selected_form = form_codes[frame.args[2]] -- get the specified form
if single_set == p_name or (single_set == p_it and selected_form == 4) then
-- handles using their username
return frame.args[1] .. p_name[selected_form]
elseif selected_form <= #single_set then
return single_set[selected_form]
else
-- handles a special case for unspecified contracted forms
return single_set[1] .. "'s"
end
end
--[[
Gets verbal agreement of a pronoun set.
Returns an integer.
0 - third person plural agreement
1 - third person singular agreement
2 - first person agreement
args[1] is the user
args[2] is the random seed offset
]]
function p.get_pronoun_agreement( frame )
single_set = select_pronoun_set(frame.args[1], frame.args[2])
-- if it doesn't have contraction forms specified, it probably needs an -s
if #single_set < 6 then
return 1
elseif single_set == p_i then
return 2
elseif single_set[6]:sub(-3) == "'re" then
-- if the sixth form ends in "'re", it's likely to not need an -s suffix on its verbs
return 0
else
return 1
end
end
return p