gender utilities #34

Parent #72Owner #29Flags readSource hellcore/hellcore.db

Aliases: Gender_Utilities

9 verbs · 26 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
setthis none thisrxd#3426
addthis none thisrxd#3424
get_pronounthis none thisrxd#3427
get_conj*ugationthis none thisrxd#3438
_verb_pluralthis none thisrxd#3431
_verb_singularthis none thisrxd#3418
_dothis none thisrxd#3442
pronoun_subthis none thisrxd#3453
set_oldthis none thisrxd#348

Properties

PropertyDefinerFlagsOwnerValue
is_plural#34rc#29
list of 11{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
have#34rc#29
list of 11{"has", "has", "has", "has", "has", "has", "have", "have", "have", "have", "has"}
be#34rc#29
list of 11{"is", "is", "is", "is", "is", "is", "are", "am", "are", "are", "is"}
pronouns#34rc#29
list of 10{"ps", "po", "pp", "pq", "pr", "psc", "poc", "ppc", "pqc", "prc"}
genders#34rc#29
list of 11{"neuter", "male", "female", "either", "Spivak", "splat", "plural", "egotistical", "royal", "2nd", "anonymous"}
ps#34rc#29
list of 11{"it", "he", "she", "s/he", "e", "*e", "they", "I", "we", "you", "they"}
po#34rc#29
list of 11{"it", "him", "her", "him/her", "em", "e", "them", "me", "us", "you", "them"}
pp#34rc#29
list of 11{"its", "his", "her", "his/her", "eir", "h*", "their", "my", "our", "your", "their"}
pq#34rc#29
list of 11{"its", "his", "hers", "his/hers", "eirs", "h*s", "theirs", "mine", "ours", "yours", "theirs"}
pr#34rc#29
list of 11{"itself", "himself", "herself", "(him/her)self", "emself", "h*self", "themselves", "myself", "ourselves", "yourself", "themself"}
psc#34rc#29
list of 11{"It", "He", "She", "S/he", "E", "*E", "They", "I", "We", "You", "They"}
poc#34rc#29
list of 11{"It", "Him", "Her", "Him/her", "Em", "E", "Them", "Me", "Us", "You", "Them"}
ppc#34rc#29
list of 11{"Its", "His", "Her", "His/her", "Eir", "H*", "Their", "My", "Our", "Your", "Their"}
pqc#34rc#29
list of 11{"Its", "His", "Hers", "His/hers", "Eirs", "H*s", "Theirs", "Mine", "Ours", "Yours", "Theirs"}
prc#34rc#29
list of 11{"Itself", "Himself", "Herself", "(Him/her)self", "Emself", "H*self", "Themselves", "Myself", "Ourselves", "Yourself", "Themself"}
help_msg#72rc#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#1rc#29{"Gender_Utilities"}
description#1rc#29{"This is the gender utilities utility package. See `help $gender_utils' for more details."}
object_size#1r#29{13999, 1298433815}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #72 Generic Utilities Package#1 root

Children: none

Call graph

calls n34_0 #34:set n20_22 #20:find_prefix n34_0->n20_22 n34_1 #34:add n34_1->n34_0 n45_0 #45:has_property n34_1->n45_0 n107_43 #107:tell n34_1->n107_43 n34_3 #34:get_conj*ugation n34_4 #34:_verb_plural n34_3->n34_4 n34_5 #34:_verb_singular n34_3->n34_5 n20_15 #20:capitalize n34_3->n20_15 n34_4->n34_4 n34_5->n34_5 n34_6 #34:_do n34_6->n34_6 n34_2 #34:get_pronoun n34_6->n34_2 n34_7 #34:pronoun_sub n34_7->n34_6 n34_7->n34_7 n20_33 #20:_cap_property n34_7->n20_33

Source

set

Spec this none thisFlags rxdOwner #361Definer #34

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #34

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

Spec this none thisFlags rxdOwner #29Definer #34

Referenced by

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

Spec this none thisFlags rxdOwner #29Definer #34

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

Spec this none thisFlags rxdOwner #29Definer #34

Referenced by

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

Spec this none thisFlags rxdOwner #29Definer #34

Referenced by

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

Spec this none thisFlags rxdOwner #29Definer #34

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #34

Referenced by

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

Spec this none thisFlags rxdOwner #361Definer #34

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;