NounPhraseclassparser.t[1682]

A NounPhrase object represents a noun phrase within a command line. This class handles the mapping from the text of the noun phrase in the input to the game-world objects that the noun phrase refers to.

This object encompasses a core noun phrase plus all of its qualifiers. Qualifiers can themselves be noun phrases: possessives, locationals, and contents phrases contain subsidiary noun phrases, so we represent these qualifiers with subsidiary NounPhrase objects.

class NounPhrase :   object

Superclass Tree   (in declaration order)

NounPhrase
        object

Subclass Tree  

NounPhrase
        LiteralPhrase
        NumberPhrase
        TopicPhrase

Global Objects  

(none)

Summary of Properties  

contPrep  contQual  coreProd  determiner  disambigNameList  errName  errNameProd  exclusions  locQual  locType  matches  objs  ordinal  parent  possQual  prod  pronoun  quantifier  role  tokens 

Summary of Methods  

addContents  addExclusionItem  addLiteral  addLocation  addMatches  addOrdinal  addPossessive  addQuantifier  ambigError  applyContQual  applyDisambig  applyExclusion  applyLocational  applyPossessive  buildObjList  clone  construct  contains  disambiguate  expandErrName  isAllEquivalent  isMultiple  matchNameScope  matchVocab  matchVocabPoss  resolveAll  resolveReflexives  selectObjects 

Properties  

contPrepparser.t[2960]

the preposition of the contents qualifier

contQualparser.t[2957]
the contents qualifier phrase, if any ("the bucket OF WATER")

coreProdparser.t[2935]
the grammar match for the core noun phrase; this is the part that names a single object, stripped of all qualifiers (such as possessives, articles, quantifiers, and locational phrases)

determinerparser.t[2973]
the determiner, if any, as a Determiner object

disambigNameListparser.t[2982]
the name list from the disambiguation query

errNameparser.t[1732]
By default, use the original input text of my "core" production as the name we show for this noun phrase in error messages. The core production is the noun phrase minus any qualifiers (articles, possessives, locational phrases, etc).

As we successfully resolve qualifiers, we'll expand this to include the qualifying phrases. Any error we find after resolving a qualifier will necessary apply to the qualified form, so we want to include the qualifier in any error message.

For example, if the original phrase is BUCKET OF FISH ON TABLE, we'll start out with the core phrase of BUCKET. We'll next resolve the contents qualifier, OF FISH. Assuming that we find a BUCKET OF FISH, that becomes the new error name. If we then fail to find such an object ON TABLE, we'll be able to report that there's no BUCKET OF FISH on the table. This is better than reporting that we don't see any BUCKET on the table, because there could in fact be a different bucket on the table.

errNameProdparser.t[1735]
the source of the error name is initially the core production

exclusionsparser.t[2979]
the exclusion list, if any (this is the list following EXCEPT or BUT in a phrase like ALL EXCEPT THE RED ONES)

locQualparser.t[2947]
the locational qualifier phrase, if any ("the box ON THE SHELF")

locTypeparser.t[2954]
The locational qualifier relationship, as a LocType object. (This is stored on the locational qualifier noun phrase itself, not on the underlying noun phrase it qualifies.)

matchesparser.t[2833]
List of NPMatch objects. This is populated during the matchName phase with the list of possible vocabulary matches, and then reduced during disambiguation to the final set.

objsparser.t[2840]
List of resolved objects. This is populated after disambiguation from the 'matches' set - it contains the same objects, but simply the objects rather than the NPMatch wrappers.

ordinalparser.t[2970]
The ordinal value, if any, as a number: for "the third one", this is 3. This is intended for use in disambiguation replies, to let the user pick out an item by its position in the offered list.

parentparser.t[2925]
the NounPhrase we qualify, if we're a possessive or locational

possQualparser.t[2944]
the possessive qualifier, if any ("BOB'S box")

prodparser.t[2928]
the grammar production match object for this noun phrase

pronounparser.t[2941]
the pronoun, if any, as a Pronoun object

quantifierparser.t[2963]
the quantifier, if any, as a number: for "five books", this is 5

roleparser.t[2922]
the Command list we're a part of (&dobjNPs, &iobjNPs, etc: the Command overrides this to the actual list property for a primary noun phrase, and for qualifiers such as possessives, this inherited version looks it up via the parent)

tokensparser.t[2938]
the literal tokens making up the noun phrase

Methods  

addContents (prep, prod)parser.t[2853]

add a contents qualifier, returning the new noun phrase

addExclusionItem (prod)parser.t[2888]
add an exclusion list item

addLiteral (tok)parser.t[2843]
add a literal to this phrase

addLocation (locType, prod)parser.t[2863]
add a locational qualifier, returning the new noun phrase

addMatches (vec, lst, match)parser.t[1906]
Add matching objects to a match vector. 'lst' can be a list or vector of objects, or a single object. 'match' is the MatchXxx flag value returned from the object name match, if applicable.

addOrdinal (num)parser.t[2882]
add an ordinal, given as an integer value

addPossessive (prod)parser.t[2846]
add a possessive qualifier, returning the new noun phrase

addQuantifier (num)parser.t[2876]
add a quantifier, given as an integer value

ambigError (cmd)parser.t[2472]
Throw an ambiguous noun phrase error for the current match list.

applyContQual ( )parser.t[2137]
Apply this contents qualifier phrase's qualification. This filters the underlying (parent) noun list to keep only objects that contain the object(s) named in this noun list.

applyDisambig (cmd, ambigMatches, nameList)parser.t[2545]
Apply this noun phrase as a disambiguation reply to the given original list of matches to an ambiguous noun phrase.

applyExclusion (cmd)parser.t[2204]
Apply an exclusion item. This resolves the vocabulary for the exclusion phrase and filters the matching item(s) noun phrase out of the parent list.

applyLocational ( )parser.t[2166]
Apply this locational phrase's qualification. This filters the underlying (parent) noun list to keep only objects located within the object(s) named in this noun phrase.

applyPossessive ( )parser.t[2100]
Apply this possessive phrase's qualification. This filters the underlying (parent) noun list to keep only objects owned by the object(s) named in this noun phrase.

buildObjList ( )parser.t[2823]
Build the 'objs' list from the match list

clone ( )parser.t[1695]
clone - create a modifiable copy based on this original noun phrase

construct (parent, prod)parser.t[1684]
create

contains (np)parser.t[1770]
Does this NounPhrase contain the given NounPhrase? Returns true if NounPhrase is self, or one of our qualifier noun phrases contains it.

disambiguate (cmd, num, action)parser.t[2383]
Disambiguate the match list to select the given target number of objects.

expandErrName (np)parser.t[1742]
Expand the error-message name to include the given qualifier. We'll find the common parent of the core production and the given qualifier's production, and use its text as the new error name.

isAllEquivalent (matchList)parser.t[2373]
Determine whether all matches in the matchList are impossible to disambiguate.

isMultiple ( )parser.t[2909]
Does this noun phrase refer to multiple objects structurally? This is true if any the matches used plural words, or the determiner is All, or we have a quantifier greater than 1.

matchNameScope (cmd, scope)parser.t[1920]
Find the vocabulary matches for a given noun phrase within a given scope list. Add all of the matches to the given vector.

matchVocab (cmd)parser.t[1786]
Get the list of objects matching the vocabulary words in our noun phrase. Populates our 'matches' property with a vector of matching objects. This doesn't look at any of our qualifiers, or attempt to disambiguate contextually; it simply finds everything in scope that the noun phrase could refer to.

matchVocabPoss (cmd)parser.t[1986]
Match vocabulary for a possessive qualifier phrase.

Possessive matching has somewhat different rules than for ordinary noun phrases.

First, possessive pronouns (HIS, HER, ITS, THEIR) *can* act like reflexives, in that they can refer back to earlier clauses in the same predicate: ASK BOB ABOUT HIS MOTHER. However, they can also refer to previous commands: SEARCH BOB; TAKE HIS WALLET. The deciding factor is whether or not there's an earlier noun phrase in the command that matches in gender and number; if so, we use the reflexive meaning, otherwise we use the external referent.

Second, the scope for ordinary noun phrases has to be expanded to include the owners of the objects in scope. If we have a wallet that we know belongs to Bob, we should be able to refer to it as "Bob's wallet" whether or not Bob himself is in scope. So, for the purposes of the possessive, Bob is in scope even if he wouldn't be for an ordinary noun phrase.

resolveAll (cmd)parser.t[2742]
Resolve ALL. This is called on a separate pass after selectObjects(), because two-object verbs sometimes resolve ALL in one slot according to the selection in the other slot.

resolveReflexives (cmd)parser.t[2787]
Resolve reflexive pronouns. Our Command calls this AFTER resolving all of the regular noun phrases, because reflexives refer back to other nouns in the same command.

selectObjects (cmd)parser.t[2255]
Select the objects from among the vocabulary matches. This narrows the list of possible vocabulary matches for our noun phrase to find the actual object or objects the player is referencing.

When this is called, we've already filled in the match list with all objects in scope that match the vocabulary of the core noun phrase (including non-reflexive pronouns and ALL), and we've applied any possessive, locational, and exclusion qualifiers. What we're left with is the list of in-scope objects that meet all of the specifications contained in the entire noun phrase. In other words, we've squeezed all available information out of the noun phrase itself. If the result is ambiguous, then, we'll have to look beyond the noun phrase, to the broader semantic content of the overall command.

There are three possible "goals" for what our final object list should look like after disambiguation. Only one goal applies to each particular noun phrase; which it is depends on the grammar of the phrase:

1. Definite mode: TAKE BOOK, TAKE THE BOOK, TAKE BOTH BOOKS, TAKE THE THREE BOOKS. The goal in definite mode is to choose the given number of objects, *and* to make sure that the player could *only* have meant those precise objects. In other words, we're not allowed to make an arbitrary choice: in natural language, the definite mode says that the speaker believes the listener knows which *particular* object or objects the speaker is referring to. If we're not absolutely sure which objects the player is talking about, we have a disagreement with the player's apparent expectations and must ask for clarification.

2. Indefinite mode: TAKE A BOOK, TAKE ANY BOOK, TAKE TWO BOOKS. The goal is to choose the given number of objects from the possible matches, arbitrarily choosing from the available objects.

3. Plural mode: TAKE BOOKS, TAKE THE BOOKS, TAKE ALL BOOKS. The goal here is to choose all of the matching objects.

Adv3Lite Library Reference Manual
Generated on 03/07/2024 from adv3Lite version 2.1