LMentionableclass | english.t[44] |
Superclass Tree | Subclass Tree | Global Objects | Property Summary | Method Summary | Property Details | Method Details |
This is the root class for objects that the player can mention in commands. The key feature of these objects is that they can match noun phrases in command input. The library subclasses this base class with Mentionable. This class provides the part of the class that varies by language.
[Required]
class
LMentionable : object
LMentionable
Mentionable
Thing
Actor
Player
Button
Collective
DispensingCollective
Consultable
Container
Booth
OpenableContainer
KeyedContainer
LockableContainer
Door
DSDoor
SymDoor
SecretDoor
Fixture
CollectiveGroup
MobileCollectiveGroup
Component
ContainerDoor
Decoration
Distant
RoomPart
Ceiling
DefaultWall
SensoryEmanation
Noise
SimpleNoise
Odor
SimpleOdor
Unthing
Enterable
Heavy
Floor
Food
Immovable
Key
Lever
MinorItem
Passage
DSPassage
SymPassage
PathPassage
DSPathPassage
SymPathPassage
RearContainer
Room
OutdoorRoom
ScenItem
MultiScenItem
Settable
Dial
NumberedDial
SimpleAttachable
AttachableComponent
NearbyAttachable
Attachable
StairwayDown
StairwayUp
DSStairway
SymStairway
SubComponent
Surface
Platform
Bed
Chair
Switch
Flashlight
Underside
Wearable
Topic
acronymPluralPat
alphaCharPat
aName
apostPluralPat
apostSPat
deannotatePat
dictComp
dummyName
elevenEighteenPat
emptyVocabWords
esPluralPat
firstWordPat
heName
herName
hersName
himName
iesPluralPat
irregularPlurals
isHer
isHim
isIt
lastWordPat
leadingTagOrQuotePat
menPluralPat
objInName
objIntoName
objName
objOutOfName
oneLetterAnWordPat
oneLetterWordPat
ownerNamed
pluralPat
posPat
possAdj
possEnding
possNoun
prepList
prepPhrasePat
prepWordPat
pronounMap
properNamePat
properPat
reflexiveName
specialAOrAn
tagOrQuotePat
thatName
thatObjName
theName
theObjName
trimPat
truncationLength
weakWordPat
addDictWord
addVocab
addVocabWord
aNameFrom
aNameFromPoss
classInit
contify
distinguishedName
ifPronoun
inheritVocab
initVocab
initVocabWord
locify
matchPronoun
pluralNameFrom
pluralWordFrom
possessify
pronoun
removeVocabWord
replaceVocab
theNameFrom
theNameIs
acronymPluralPat | english.t[1860] |
alphaCharPat | english.t[1720] |
aName | english.t[50] |
[Required]
apostPluralPat | english.t[1857] |
apostSPat | english.t[1179] |
deannotatePat | english.t[1292] |
dictComp | english.t[1863] |
dummyName | english.t[1881] |
elevenEighteenPat | english.t[1721] |
emptyVocabWords | english.t[193] |
[Required]
esPluralPat | english.t[1848] |
firstWordPat | english.t[1716] |
heName | english.t[120] |
herName | english.t[135] |
hersName | english.t[142] |
himName | english.t[127] |
iesPluralPat | english.t[1851] |
irregularPlurals | english.t[1842] |
isHer | english.t[223] |
isHim | english.t[222] |
isIt | english.t[230] |
lastWordPat | english.t[1779] |
leadingTagOrQuotePat | english.t[1715] |
menPluralPat | english.t[1854] |
objInName | english.t[401] |
objIntoName | english.t[408] |
objName | english.t[79] |
objOutOfName | english.t[414] |
oneLetterAnWordPat | english.t[1719] |
oneLetterWordPat | english.t[1718] |
ownerNamed | english.t[200] |
pluralPat | english.t[1299] |
posPat | english.t[1296] |
possAdj | english.t[93] |
However, it does vary for pronouns. By default, we check the name to see if it's a pronoun, and apply the correct pronoun mapping if so.
possEnding | english.t[115] |
possNoun | english.t[108] |
However, it diverges for some of the pronouns: "my" vs "mine", "her" vs "hers", "their" vs "theirs", "our" vs "ours". We check the name to see if it's a pronoun, and apply the appropriate pronoun mapping if so.
prepList | english.t[1289] |
prepPhrasePat | english.t[1775] |
prepWordPat | english.t[1282] |
pronounMap | english.t[1873] |
properNamePat | english.t[857] |
properPat | english.t[1305] |
reflexiveName | english.t[161] |
specialAOrAn | english.t[1711] |
tagOrQuotePat | english.t[1714] |
thatName | english.t[150] |
thatObjName | english.t[158] |
theName | english.t[57] |
[Required]
theObjName | english.t[60] |
trimPat | english.t[1845] |
truncationLength | english.t[1869] |
weakWordPat | english.t[1285] |
addDictWord (w, partOfSpeech, matchFlags) | english.t[1185] |
addVocab (voc) | english.t[1229] |
addVocabWord (word, matchFlags) | english.t[1272] |
aNameFrom (str) | english.t[1493] |
By default, we'll use the article "a" if the name starts with a consonant, or "an" if it starts with a vowel.
If the name starts with a "y", we'll look at the second letter; if it's a consonant, we'll use "an", otherwise "a" (hence "an yttrium block" but "a yellow brick").
If the object is marked as a mass noun or having plural usage, we will use "some" as the article ("some water", "some shrubs"). If the string has a possessive qualifier, we'll make that "some of" instead ("some of Bob's water").
Some objects will want to override the default behavior, because the lexical rules about when to use "a" and "an" are not without exception. For example, silent-"h" words ("honor") are written with "an", and "h" words with a pronounced but weakly stressed initial "h" are sometimes used with "an" ("an historian"). Also, some 'y' words might not follow the generic 'y' rule.
'U' words are especially likely not to follow any lexical rule - any 'u' word that sounds like it starts with 'y' should use 'a' rather than 'an', but there's no good way to figure that out just looking at the spelling (consider "unassuming", " unimportant word", or "a unanimous decision" and "an unassuming man"). We simply always use 'an' for a word starting with 'u', but this will have to be overridden when the 'u' sounds like 'y'.
aNameFromPoss (str) | english.t[1698] |
In English, there's a special case where the regular indefinite name format differs from the possessive format, which is why we need this separate method in the English module. Specifically, if the basic name is a plural or mass noun, we have to use "some of" in the possessive case, rather than the usual "some": "some water" in the normal case, but "some of Bob's water" in the possessive case.
classInit ( ) | english.t[268] |
For the English version, we take the opportunity to set up the main parser Dictionary object, and initialize the plural table. The plural table is a lookup table we build from the plural list, for quicker access during execution.
[Required]
contify (obj, str) | english.t[1454] |
distinguishedName (article, distinguishers) | english.t[1321] |
'article' indicates which kind of article to use: Definite ("the"), Indefinite ("a", "an", "some"), or nil (no article). 'distinguishers' is a list of Distinguisher object that are being used to identify this object uniquely. Our job is to elaborate the object's name with all of the qualifying phrases implied by the distinguishers.
[Required]
ifPronoun (prop, str) | english.t[168] |
inheritVocab ( ) | english.t[870] |
initVocab ( ) | english.t[546] |
The vocab string is designed to make it as quick and easy as possible to define an object's name and vocabulary. To the extent possible, we derive the vocabulary from the name, so for many objects the whole definition will just look like the object name. However, we also make it possible to define as much extra vocabulary beyond the name as needed, and to control the way the words making up the name are handled in terms of their parts of speech.
The 'vocab' string has this overall syntax:
vocab = 'article short name; adjectives; nouns; pronouns'
You don't have to include all of the parts; you can simply stop when you're done, so it's valid, for example, to just write the 'short name' part. It's also fine to include an empty part: if you have extra nouns to list, but no adjectives, you can say 'short name;;nouns'.
The 'article' is optional. This can be one of 'a', 'an', 'some', or '()'. If it's 'a' or 'an', and this differs from what we'd automatically generate based on the first word of the short name, we automatically enter the first word into the list of special cases for a/an words. If it's 'some', we automatically set massNoun=true for the object. If it's '-', we set qualified=true ('()' means that the name doesn't take an article at all).
Note that if you want to use 'a', 'an', 'some', or '()' as the first word of the actual short name, you simply need to add the desired article in front of it: 'an a tile from a scrabble set'.
The short name gives name that we display whenever the parser needs to show the object in a list, an announcement, etc.
If the short name consists entirely of capitalized words (that is, if every word starts with a capital letter), and the 'proper' property isn't explicitly set for this object, we'll set 'proper' to true to indicate that this is a proper name.
We also try to infer the object's vocabulary words from the short name. We first break off any prepositional phrases, if we see the prepositions 'to', 'of', 'from', 'with', or 'for'. We then assume that the FIRST phrase is of the form 'adj adj adj... noun' - that is, zero or more adjectives followed by a noun; and that the SECOND and subsequent phrases are entirely adjectives. You can override the part-of-speech inference by putting the actual part of speech immediately after a word (with no spaces) in square brackets: 'John[n] Smith' overrides the assumption that 'John' is an adjective. Use [n] to make a word a noun, [adj] to make it an adjective, [prep] to make it a preposition, and [pl] to make it a plural. You can also add [weak] to make it a weak token (one on which the object won't be matched alone), or equivalently, enclose the word in parentheses. These annotations are stripped out of the name when it's displayed.
We consider ALL of the words in the short name's second and subsequent phrases (the prepositional phrases) to be adjectives, except for the preposition words themselves, which we consider to be prepositions. This is because these phrases all effectively qualify the main phrase, so we don't consider them as "important" to the object's name. This helps the parser be smarter about disambiguation, without bothering the user with clarifying questions all the time. When the player types "garage", we'll match the "key to the garage" object as well as the "garage" object, but if both objects are present, we'll know to choose the garage over the key because the noun usage is a better match to what the user typed.
We automatically ignore articles (a, an, the, and some) as vocabulary words when they immediately follow prepositions in the short name. For example, in 'key to the garage', we omit 'the' as a vocabulary word for the object because it immediately follows 'to'. We also omit 'to', since we don't enter the prepositions as vocabulary. We do the complementary work on parsing, by ignoring these words when we see them in the command input in the proper positions. These words are really structural parts of the grammar rather than parts of the object names, so the parser can do a better job of recognizing noun phrases by considering the grammatical functions of these words.
For many (if not most) objects, the short name won't be enough to state all of the vocabulary words you want to recognize for the object in command input. Trying to cram every possible vocabulary word into the short name would usually make for an unwieldy display name. Fortunately, it's easy to add input vocabulary words that aren't displayed in the name. Just add a semicolon, then the adjectives, then another semicolon, then the nouns.
Note that there's no section for adding extra prepositions, but you can still add them. Put the prepositions in the adjective list, and explicitly annotate each one as a preposition by adding "[prep]" at the end, as in "to[prep]".
Next, there's the matter of plurals. For each noun, we'll try to automatically infer a plural according to the spelling pattern. We also have a table of common irregular plurals that we'll apply. For irregular words that aren't in the table, you can override the spelling-based plural by putting the real plural in braces immediately after the noun, with no spaces. Start with a hyphen to specify a suffix; otherwise just write the entire plural word. For example, you could write 'man{men}' or 'child{-ren}' (although these particular irregular plurals are already in our special-case list, so the custom plurals aren't actually needed in these cases). You can use plural annotations in the short name as well as the extra noun list; they'll be removed from the short name when it's displayed. We don't try to generate a plural for a proper noun (a noun that starts with a capital letter), but you can provide explicit plurals.
For words longer than the truncation length in the string comparator, you can set the word to match exactly by adding '=' as the last character. This also requires exact character matching, rather than allowing accented character approximations (e.g., matching 'a' in the input to 'a-umlaut' in the dictionary).
We automatically assume that plurals should be matched without truncation. This is because English plurals are usually formed with suffixes; if the user wants to enter a plural, they'll have to type the whole word anyway, because that's the only way you make it all the way to the suffix. You can override this assumption for a given plural by adding '~' at the end of the plural. This explicitly allows truncated and character approximation matches.
Finally, the 'pronouns' section gives a list of the pronouns that this word can match. You can include 'it', 'him', 'her', and 'them' in this section. We'll automatically set the isIt, isHim, isHer, and plural properties to true when we see the corresponding pronouns.
[Required]
initVocabWord (w, matchFlags) | english.t[982] |
'matchFlags' is a combination of MatchXxx values. This should minimally provide the part of speech as one of MatchAdj, MatchNoun, or MatchPlural. You can also include MatchNoTrunc to specify that user input can only match this word without any truncation, and MatchNoApprox to specify that input can only match without character approximations (e.g., 'a' matching 'a-umlaut').
locify (obj, str) | english.t[1439] |
matchPronoun (p) | english.t[344] |
English pronouns have gender and number. (Some other languages have other attributes, such as animation - whether or not they refer to living creatures.)
This routine doesn't tell us if the object is a *current* antecedent for the pronoun. The current antecedent is a function of the command history. This routine only tells us whether this object is a match in terms of grammatical attributes for the pronoun.
Note that this routine can and should ignore first-person and second-person pronouns. Those pronouns are relative to the speaker, so the parser handles them directly.
[Required]
pluralNameFrom (str) | english.t[1738] |
This can only deal with simple adjective-noun forms. For more complicated forms, particularly for compound words, it must be overridden (e.g., "Attorney General" -> "Attorneys General", "man-of-war" -> "men-of-war"). We recognize a fairly extensive set of special cases (child -> children, man -> men), as listed in the irregularPlural lists in any CustomVocab objects. Add new items to the irregular plural list by creating one or more CustomVocab objects with their own irregularPlural lists.
pluralWordFrom (str, apost) | english.t[1787] |
possessify (article, obj, str) | english.t[1418] |
Note that we must add to 'str', not the base name of the object. We might be using a variation on the name (such as the disambiguation name), or we might have already adorned the name with other qualifiers.
'article' specifies the usage: Definite, Indefinite, or nil for no article. We DON'T actually add the article here; rather, this tells us the form that the name will take when the caller is done with it, so we should use a suitable form of the possessive phrasing to the extent it varies by article. In English, it does vary. In the Definite case, the possessive effectively replaces the article: "the book" becomes "Bob's book". In the Indefinite case, the possessive has to be rephrased prepositionally so that the article can still be included: "a book" becomes "a book of Bob's". Mass nouns are a further special case: "some water" becomes "some of Bob's water".
The default behavior is as follows. In Definite mode, we return "<name>'s <string>". In Indefinite mode, we return "<string> of <name>" (for a final result like "a book of Bob's").
pronoun ( ) | english.t[364] |
[Required]
removeVocabWord (word, matchFlags?) | english.t[1263] |
replaceVocab (voc) | english.t[1209] |
theNameFrom (str) | english.t[210] |
theNameIs ( ) | english.t[238] |