gender utilities #34
Aliases: Gender_Utilities
9 verbs · 26 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
set | this none this | rxd | #34 | 26 |
add | this none this | rxd | #34 | 24 |
get_pronoun | this none this | rxd | #34 | 27 |
get_conj*ugation | this none this | rxd | #34 | 38 |
_verb_plural | this none this | rxd | #34 | 31 |
_verb_singular | this none this | rxd | #34 | 18 |
_do | this none this | rxd | #34 | 42 |
pronoun_sub | this none this | rxd | #34 | 53 |
set_old | this none this | rxd | #34 | 8 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
is_plural | #34 | rc | #29 | list of 11{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1} |
have | #34 | rc | #29 | list of 11{"has", "has", "has", "has", "has", "has", "have", "have", "have", "have", "has"} |
be | #34 | rc | #29 | list of 11{"is", "is", "is", "is", "is", "is", "are", "am", "are", "are", "is"} |
pronouns | #34 | rc | #29 | list of 10{"ps", "po", "pp", "pq", "pr", "psc", "poc", "ppc", "pqc", "prc"} |
genders | #34 | rc | #29 | list of 11{"neuter", "male", "female", "either", "Spivak", "splat", "plural", "egotistical", "royal", "2nd", "anonymous"} |
ps | #34 | rc | #29 | list of 11{"it", "he", "she", "s/he", "e", "*e", "they", "I", "we", "you", "they"} |
po | #34 | rc | #29 | list of 11{"it", "him", "her", "him/her", "em", "e", "them", "me", "us", "you", "them"} |
pp | #34 | rc | #29 | list of 11{"its", "his", "her", "his/her", "eir", "h*", "their", "my", "our", "your", "their"} |
pq | #34 | rc | #29 | list of 11{"its", "his", "hers", "his/hers", "eirs", "h*s", "theirs", "mine", "ours", "yours", "theirs"} |
pr | #34 | rc | #29 | list of 11{"itself", "himself", "herself", "(him/her)self", "emself", "h*self", "themselves", "myself", "ourselves", "yourself", "themself"} |
psc | #34 | rc | #29 | list of 11{"It", "He", "She", "S/he", "E", "*E", "They", "I", "We", "You", "They"} |
poc | #34 | rc | #29 | list of 11{"It", "Him", "Her", "Him/her", "Em", "E", "Them", "Me", "Us", "You", "Them"} |
ppc | #34 | rc | #29 | list of 11{"Its", "His", "Her", "His/her", "Eir", "H*", "Their", "My", "Our", "Your", "Their"} |
pqc | #34 | rc | #29 | list of 11{"Its", "His", "Hers", "His/hers", "Eirs", "H*s", "Theirs", "Mine", "Ours", "Yours", "Theirs"} |
prc | #34 | rc | #29 | list of 11{"Itself", "Himself", "Herself", "(Him/her)self", "Emself", "H*self", "Themselves", "Myself", "Ourselves", "Yourself", "Themself"} |
help_msg | #72 | rc | #29 | list of 18{"Defines the list of standard genders, the default pronouns for each, and routines for adding or setting pronoun properties on any gendered object.", "", "Properties:", " .genders -- list of standard genders", " .pronouns -- list of pronoun properties", " .ps .po .pp .pq .pr .psc .poc .ppc .pqc .prc ", " -- lists of pronouns for each of the standard genders", "", " If foo is of gender this.gender[n], ", " then the default pronoun foo.p is this.p[n] ", " (where p is one of ps/po/pp/pq...)", "", "Verbs:", " :set(object,newgender) -- changes pronoun properties to match new gender.", " :add(object[,perms[,owner]]) -- adds pronoun properties to object.", "", " :get_pronoun (which,object) -- return pronoun for a given object", " :get_conj*ugation(verbspec,object) -- return appropriately conjugated verb"} |
aliases | #1 | rc | #29 | {"Gender_Utilities"} |
description | #1 | rc | #29 | {"This is the gender utilities utility package. See `help $gender_utils' for more details."} |
object_size | #1 | r | #29 | {13999, 1298433815} |
hidden_verbs | #1 | rc | #29 | <clear> |
phelp_msg | #1 | rc | #29 | <clear> |
weight | #1 | rc | #29 | <clear> |
owner_verbs | #1 | rc | #29 | <clear> |
plural_name | #1 | rc | #29 | <clear> |
client_image | #1 | rc | #29 | <clear> |
listening | #1 | rc | #29 | <clear> |
Ancestry
Ancestors (nearest first): #72 Generic Utilities Package → #1 root
Children: none
Call graph
Source
set
Referenced by
- #34:add line 22:
this:set - #49:make-core-database line 71:
$gender_utils:set - #89:_morph line 3:
$gender_utils:set - #107:set_gender line 8:
$gender_utils:set - #142:_spawn_gender line 1:
$gender_utils:set - #148:setup line 9:
$gender_utils:set
Source
1"$gender_utils:set(object,gender) --- sets the pronoun properties of object."; 2"gender is a string: one of the strings in $gender_utils.genders, the list of rcognized genders. If the gender change is successful, the (full) name of the gender (e.g., \"male\") is returned. E_NONE is returned if gender does not match any recognized gender. Any other error encountered (e.g., E_PERM, E_PROPNF) is likewise returned and the object's pronoun properties are left unaltered."; 3{object, gender} = args; 4if (this == object) 5return E_DIV; 6elseif (gnum = $string_utils:find_prefix(gender, this.genders)) 7gender = this.genders[gnum]; 8else 9return E_NONE; 10endif 11save = {}; 12prons = this.pronouns; 13for p in (prons) 14save = {@save, e = `object.(p) ! ANY'}; 15if ((typeof(e) != STR) || (typeof(e = `object.(p) = this.(p)[gnum] ! ANY') == ERR)) 16for i in [1..length(save) - 1] 17object.(prons[i]) = save[i]; 18endfor 19return e; 20endif 21endfor 22object.gender = gender; 23"if (has_property(object, \"body_parts\") && $lu:list_is_a(object.body_parts, $bodyparts.groin))"; 24" $bodyparts.((gender == \"male\") ? \"penis\" | ((gender == \"female\") ? \"vagina\" | \"groin\")):add_to(object);"; 25"endif"; 26return gender;
add
Referenced by
none
Source
1"$gender_utils:add(object[,perms[,owner]])"; 2"--- adds pronoun properties to object if they're not already there."; 3" perms default to \"rc\", owner defaults to the object owner."; 4set_task_perms(caller_perms()); 5{object, ?perms = "rc", ?owner = object.owner} = args; 6prons = this.pronouns; 7e = 1; 8for p in (prons) 9if (!$object_utils:has_property(object, p)) 10e = `add_property(object, p, "", {owner, perms}) ! ANY'; 11if (typeof(e) == ERR) 12player:tell("Couldn't add ", object, ".", p, ": ", e); 13return; 14endif 15elseif ((typeof(object.(p)) != STR) && (typeof(e = `object.(p) = "" ! ANY') == ERR)) 16player:tell("Couldn't reset ", object, ".", p, ": ", e); 17return; 18elseif (!object.(p)) 19e = 0; 20endif 21endfor 22if ((!e) && (ERR == typeof(e = this:set(object, "neuter")))) 23player:tell("Couldn't initialize pronouns: ", e); 24endif
get_pronoun
Referenced by
- #34:_do line 25:
this:get_pronoun - #75:display_quota_summary line 3:
$gender_utils:get_pronoun
Source
1"get_pronoun(key,object) => pronoun corresponding to object."; 2"key can be one of s,o,p,q,r,S,O,P,Q,R to refer to the pronoun properties relatively directly or it can be something of the form \"he/she\" or \"He/She\"."; 3"Next the object is checked for the desired pronoun property. If that doesn't exist, we look at object.gender and infer the pronoun from the corresponding $gender_utils property. If .gender doesn't exist or the object itself is invalid, we use the corresponding property on $player."; 4{key, ?object = player} = args; 5if (key[1] == ":") 6key = key[2..$]; 7endif 8if ((length(key) == 1) && (i = index("sopqrSOPQR", key, 1))) 9prop = this.pronouns[i]; 10else 11search = "$1:he$s:she$1:he/she$2:him$2:him/her$3:his/her$4:hers$4:his/hers$5:himself$5:herself$5:himself/herself"; 12i = index(search, (":" + key) + "$"); 13if (!i) 14return ""; 15endif 16cap = strcmp("a", key) > 0; 17prop = this.pronouns[toint(search[i - 1]) + (5 * cap)]; 18endif 19if (!valid(object)) 20return $player.(prop); 21elseif (STR == typeof(p = `object.(prop) ! ANY')) 22return p; 23elseif ((STR == typeof(g = `object.gender ! ANY')) && (i = g in this.genders)) 24return this.(prop)[i]; 25else 26return $player.(prop); 27endif
get_conj*ugation
Referenced by
none
Source
1"get_conj(verbspec,object) => verb conjugated according to object."; 2"verbspec can be one of \"singular/plural\", \"singular\", \"singular/\", or \"/plural\", e.g., \"is/are\", \"is\", \"is/\", or \"/are\"."; 3"The object is checked to see whether it is singular or plural. This is inferred from its .gender property. If .gender doesn't exist or the object itself is invalid, we assume singular."; 4{spec, ?object = player} = args; 5i = index(spec + "/", "/"); 6sing = spec[1..i - 1]; 7if (i < length(spec)) 8plur = spec[i + 1..$]; 9else 10plur = ""; 11endif 12cap = strcmp("a", (i == 1) ? spec[2] | spec) > 0; 13if (valid(object)) 14gender = `object.gender ! E_PROPNF'; 15i = 0; 16if (typeof(gender) == STR) 17i = gender in this.genders; 18endif 19if (i) 20if (this.is_plural[i]) 21vb = plur || this:_verb_plural(sing, i); 22else 23vb = sing || this:_verb_singular(plur, i); 24endif 25elseif (`object.is_plural ! E_PROPNF => 0') 26vb = plur || this:_verb_plural(sing, 7); 27else 28vb = sing || this:_verb_singular(plur, 1); 29endif 30else 31"invalid objects are singular; 'nothing' is singular."; 32vb = sing || this:_verb_singular(plur, 1); 33endif 34if (cap) 35return $string_utils:capitalize(vb); 36else 37return vb; 38endif
_verb_plural
Referenced by
- #34:get_conj*ugation line 21:
this:_verb_plural - #34:get_conj*ugation line 26:
this:_verb_plural - #34:_verb_plural line 7:
this:_verb_plural
Source
1{st, idx} = args; 2if (typeof(st) != STR) 3return E_INVARG; 4endif 5len = length(st); 6if ((len >= 3) && (rindex(st, "n't") == (len - 2))) 7return this:_verb_plural(st[1..len - 3], idx) + "n't"; 8elseif (i = st in {"has", "is"}) 9return this.({"have", "be"}[i])[idx]; 10elseif (st == "was") 11return (idx > 6) ? "were" | st; 12elseif ((len <= 3) || (st[len] != "s")) 13return st; 14elseif (st[len - 1] != "e") 15return st[1..len - 1]; 16"elseif ((r = (rindex(st, \"sses\") || rindex(st, \"zzes\"))) && (r == (len - 3)))"; 17elseif ((r = rindex(st, "zzes")) && (r == (len - 3))) 18return st[1..len - 3]; 19elseif ((((st[len - 2] == "h") && index("cs", st[len - 3])) || index("ox", st[len - 2])) || (st[len - 3..len - 2] == "ss")) 20return st[1..len - 2]; 21"washes => wash, belches => belch, boxes => box"; 22"used to have || ((st[len - 2] == \"s\") && (!index(\"aeiouy\", st[len - 3])))"; 23"so that <consonant>ses => <consonant>s"; 24"known examples: none"; 25"counterexample: browses => browse"; 26"update of sorts--put in code to handle passes => pass"; 27elseif (st[len - 2] == "i") 28return st[1..len - 3] + "y"; 29else 30return st[1..len - 1]; 31endif
_verb_singular
Referenced by
- #34:get_conj*ugation line 23:
this:_verb_singular - #34:get_conj*ugation line 28:
this:_verb_singular - #34:get_conj*ugation line 32:
this:_verb_singular - #34:_verb_singular line 7:
this:_verb_singular
Source
1{st, idx} = args; 2if (typeof(st) != STR) 3return E_INVARG; 4endif 5len = length(st); 6if ((len >= 3) && (rindex(st, "n't") == (len - 2))) 7return this:_verb_singular(st[1..len - 3], idx) + "n't"; 8elseif (i = st in {"have", "are"}) 9return this.({"have", "be"}[i])[idx]; 10elseif (((st[len] == "y") && (len > 1)) && (!index("aeiou", st[len - 1]))) 11return st[1..len - 1] + "ies"; 12elseif (index("sz", st[len]) && ((len > 1) && index("aeiou", st[len - 1]))) 13return (st + st[len]) + "es"; 14elseif (index("osx", st[len]) || ((len > 1) && (index("chsh", st[len - 1..len]) % 2))) 15return st + "es"; 16else 17return st + "s"; 18endif
_do
Referenced by
- #34:_do line 20:
this:_do - #34:_do line 38:
this:_do - #34:pronoun_sub line 27:
this:_do
Source
1"_do(cap,object,modifiers...)"; 2{cap, object, modifiers} = args; 3if (!modifiers) 4if (typeof(object) != OBJ) 5return tostr(object); 6elseif (!valid(object)) 7return (cap ? "N" | "n") + "othing"; 8else 9return cap ? object:titlec() | object:title(); 10endif 11elseif (modifiers[1] == ".") 12if (i = index(modifiers[2..$], ".")) 13i = i + 1; 14elseif (!(i = (index(modifiers, ":") || index(modifiers, "#")) || index(modifiers, "!"))) 15i = length(modifiers) + 1; 16endif 17if (typeof(o = `object.(modifiers[2..i - 1]) ! ANY') == ERR) 18return tostr("%(", o, ")"); 19else 20return this:_do(cap || (strcmp("a", modifiers[2]) > 0), o, modifiers[i..$]); 21endif 22elseif (modifiers[1] == ":") 23if (typeof(object) != OBJ) 24return tostr("%(", E_TYPE, ")"); 25elseif (p = this:get_pronoun(modifiers, object)) 26return p; 27else 28return tostr("%(", modifiers, "??)"); 29endif 30elseif (modifiers[1] == "#") 31return tostr(object); 32elseif (modifiers[1] == "!") 33return this:get_conj(modifiers[2..$], object); 34else 35i = (((index(modifiers, ".") || index(modifiers, ":")) || index(modifiers, "#")) || index(modifiers, "!")) || (length(modifiers) + 1); 36s = modifiers[1..i - 1]; 37if (j = s in {"dobj", "iobj", "this"}) 38return this:_do(cap, {dobj, iobj, callers()[2][1]}[j], modifiers[i..$]); 39else 40return tostr("%(", s, "??)"); 41endif 42endif
pronoun_sub
Referenced by
- #34:pronoun_sub line 9:
this:pronoun_sub
Source
1"Experimental pronoun substitution. The official version is on $string_utils."; 2"syntax: :pronoun_sub(text[,who])"; 3"experimental version that accomodates Aladdin's style..."; 4set_task_perms($no_one); 5{old, ?who = player} = args; 6if (typeof(old) == LIST) 7plines = {}; 8for line in (old) 9plines = {@plines, this:pronoun_sub(line, who)}; 10endfor 11return plines; 12endif 13new = ""; 14here = valid(who) ? who.location | $nothing; 15objspec = "nditl"; 16objects = {who, dobj, iobj, caller, here}; 17prnspec = "sopqrSOPQR"; 18prprops = {"ps", "po", "pp", "pq", "pr", "Ps", "Po", "Pp", "Pq", "Pr"}; 19oldlen = length(old); 20while ((prcnt = index(old, "%")) && (prcnt < oldlen)) 21cp_args = {}; 22s = old[k = prcnt + 1]; 23if (brace = index("([{", s)) 24if (!(w = index(old[k + 1..oldlen], ")]}"[brace]))) 25return new + old; 26elseif (brace == 3) 27s = this:_do(0, who, old[prcnt + 2..(k = k + w) - 1]); 28else 29p = old[prcnt + 2..(k = k + w) - 1]; 30if (brace == 1) 31cp_args = {who, p}; 32elseif (p[1] == "#") 33s = (o = index(objspec, p[2])) ? tostr(objects[o]) | (("[" + p) + "]"); 34elseif (!(o = index(objspec, p[1]))) 35s = ("[" + p) + "]"; 36else 37cp_args = {objects[o], p[2..w - 1], strcmp(p[1], "a") < 0}; 38endif 39endif 40elseif (o = index(objspec, s)) 41cp_args = {objects[o], "", strcmp(s, "a") < 0}; 42elseif (w = index(prnspec, s, 1)) 43cp_args = {who, prprops[w]}; 44elseif (s == "#") 45s = tostr(who); 46elseif (s != "%") 47s = "%" + s; 48endif 49new = (new + old[1..prcnt - 1]) + ((!cp_args) ? s | ((typeof(sub = $string_utils:_cap_property(@cp_args)) != ERR) ? sub | (("%(" + tostr(sub)) + ")"))); 50old = old[k + 1..oldlen]; 51oldlen = oldlen - k; 52endwhile 53return new + old;
set_old
Referenced by
none
Source
1who = args[1]; 2gender = args[2]; 3if (gnum = gender in this.genders) 4for prop in (this.pronouns) 5who.(prop) = this.(prop)[gnum]; 6endfor 7endif 8return gender;