Resolverclass
resolver.t[31], en_us.t[3296]
Basic object resolver. An Action object creates an object resolver to mediate the process of resolving noun phrases to objects.
A resolver encapsulates a set of object resolution rules. In most cases, an action that takes only a direct object can be its own resolver, because it needs only one set of resolution rules; for this reason, this basic Resolver implementation is designed to work with the direct object. Actions with multiple objects will need separate resolvers for each object, since they might want to use different rules for the different objects.
Modified in
en_us.t[3296]:
Custom base resolver
class
Resolver
: object
Superclass Tree (in declaration order)
Resolver
` object`
Subclass Tree
Resolver
ActorResolver
IobjResolver
TAction
AttackAction
predicate(Attack)
BoardAction
predicate(Board)
BreakAction
predicate(Break)
BurnAction
predicate(Burn)
CleanAction
predicate(Clean)
ClimbAction
predicate(Climb)
ClimbDownAction
predicate(ClimbDown)
predicate(ClimbDownWhat)
ClimbUpAction
predicate(ClimbUp)
predicate(ClimbUpWhat)
CloseAction
predicate(Close)
ConsultAction
predicate(Consult)
CutAction
DetachAction
predicate(Detach)
DigAction
predicate(Dig)
DoffAction
predicate(Doff)
DrinkAction
predicate(Drink)
DropAction
predicate(Drop)
EatAction
predicate(Eat)
EnterAction
predicate(Enter)
ExamineAction
predicate(Examine)
ExtinguishAction
predicate(Extinguish)
FastenAction
predicate(Fasten)
FeelAction
predicate(Feel)
FlipAction
predicate(Flip)
FollowAction
predicate(Follow)
GetOffOfAction
predicate(GetOffOf)
GetOutOfAction
predicate(GetOutOf)
GoThroughAction
predicate(GoThrough)
JumpOffAction
predicate(JumpOff)
JumpOverAction
predicate(JumpOver)
KissAction
predicate(Kiss)
LieOnAction
predicate(LieOn)
LightAction
predicate(Light)
ListenToAction
predicate(ListenTo)
LiteralTAction
EnterOnAction
predicate(EnterOn)
predicate(EnterOnWhat)
SetToAction
predicate(SetTo)
TurnToAction
predicate(TurnTo)
TypeLiteralOnAction
predicate(TypeLiteralOn)
predicate(TypeLiteralOnWhat)
LockAction
predicate(Lock)
LookBehindAction
predicate(LookBehind)
LookInAction
predicate(LookIn)
LookThroughAction
predicate(LookThrough)
LookUnderAction
predicate(LookUnder)
MoveAction
predicate(Move)
OpenAction
predicate(Open)
PlugInAction
predicate(PlugIn)
PourAction
predicate(Pour)
PullAction
predicate(Pull)
PushAction
predicate(Push)
PushTravelAction
PushTravelDirAction
predicate(PushTravelDir)
PushAftAction
PushDownAction
PushEastAction
PushForeAction
PushInAction
PushNorthAction
PushNortheastAction
PushNorthwestAction
PushOutAction
PushPortAction
PushSouthAction
PushSoutheastAction
PushSouthwestAction
PushStarboardAction
PushUpAction
PushWestAction
PushTravelViaIobjAction
PushTravelClimbDownAction
predicate(PushTravelClimbDown)
PushTravelClimbUpAction
predicate(PushTravelClimbUp)
PushTravelEnterAction
predicate(PushTravelEnter)
PushTravelGetOutOfAction
predicate(PushTravelGetOutOf)
PushTravelThroughAction
predicate(PushTravelThrough)
ReadAction
predicate(Read)
RemoveAction
predicate(Remove)
ScrewAction
predicate(Screw)
SearchAction
predicate(Search)
SetAction
predicate(Set)
SitOnAction
predicate(SitOn)
SmellAction
predicate(Smell)
StandOnAction
predicate(StandOn)
StrikeAction
predicate(Strike)
SwitchAction
predicate(Switch)
TakeAction
predicate(Take)
TalkToAction
predicate(TalkTo)
predicate(TalkToWhat)
TasteAction
predicate(Taste)
ThrowAction
predicate(Throw)
ThrowDirAction
predicate(ThrowDir)
predicate(ThrowDirDown)
TIAction
AttachToAction
predicate(AttachTo)
predicate(AttachToWhat)
AttackWithAction
predicate(AttackWith)
BurnWithAction
predicate(BurnWith)
CleanWithAction
predicate(CleanWith)
CutWithAction
predicate(CutWith)
predicate(CutWithWhat)
DetachFromAction
predicate(DetachFrom)
DigWithAction
predicate(DigWith)
FastenToAction
predicate(FastenTo)
GiveToAction
predicate(GiveTo)
predicate(GiveToType2)
predicate(GiveToWhom)
LockWithAction
predicate(LockWith)
MoveToAction
predicate(MoveTo)
MoveWithAction
predicate(MoveWith)
PlugIntoAction
predicate(PlugInto)
predicate(PlugIntoWhat)
PourIntoAction
predicate(PourInto)
PourOntoAction
predicate(PourOnto)
PushTravelViaIobjAction
PushTravelClimbDownAction
predicate(PushTravelClimbDown)
PushTravelClimbUpAction
predicate(PushTravelClimbUp)
PushTravelEnterAction
predicate(PushTravelEnter)
PushTravelGetOutOfAction
predicate(PushTravelGetOutOf)
PushTravelThroughAction
predicate(PushTravelThrough)
PutBehindAction
predicate(PutBehind)
PutInAction
predicate(PutIn)
predicate(PutInWhat)
PutOnAction
predicate(PutOn)
PutUnderAction
predicate(PutUnder)
ScrewWithAction
predicate(ScrewWith)
ShowToAction
predicate(ShowTo)
predicate(ShowToType2)
predicate(ShowToWhom)
TakeFromAction
predicate(TakeFrom)
ThrowAtAction
predicate(ThrowAt)
ThrowToAction
predicate(ThrowTo)
predicate(ThrowToType2)
TurnWithAction
predicate(TurnWith)
UnfastenFromAction
predicate(UnfastenFrom)
UnlockWithAction
predicate(UnlockWith)
UnplugFromAction
predicate(UnplugFrom)
UnscrewWithAction
predicate(UnscrewWith)
TopicTAction
AskVagueAction
predicate(AskVague)
predicate(TellVague)
ConsultAboutAction
predicate(ConsultAbout)
predicate(ConsultWhatAbout)
ConvTopicTAction
AskAboutAction
predicate(AskAbout)
predicate(AskAboutImplicit)
predicate(AskAboutWhat)
AskForAction
predicate(AskFor)
predicate(AskWhomFor)
TellAboutAction
predicate(TellAbout)
predicate(TellAboutImplicit)
predicate(TellAboutWhat)
TellVagueAction
TravelViaAction
EnTravelVia
TurnAction
predicate(Turn)
TurnOffAction
predicate(TurnOff)
TurnOnAction
predicate(TurnOn)
TypeOnAction
predicate(TypeOn)
UnfastenAction
predicate(Unfasten)
UnlockAction
predicate(Unlock)
UnplugAction
predicate(Unplug)
UnscrewAction
predicate(Unscrew)
WearAction
predicate(Wear)
TopicQualifierResolver
TopicResolver
ConvTopicResolver
TActionTopicResolver
Global Objects
(none)
Summary of Properties
action_
actor_
equivs_
isGlobalScope
isSubResolver
issuer_
scope_
whichMessageObject
whichObject
Summary of Methods
allowAll
cacheScopeList
construct
filterAll
filterAmbiguousEquivalents
filterAmbiguousNounPhrase
filterPluralPhrase
filterPossRank
getAction
getAll
getAllDefaults
getDefaultObject
getPossessiveResolver
getPronounDefault
getQualifierResolver
getRawPronounAntecedent
getReflexiveBinding
getScopeList
getTargetActor
matchName
objInScope
resetResolver
resolvePronounAntecedent
resolveUnknownNounPhrase
selectIndefinite
withGlobals
Properties
action_
my action
actor_
the target actor object
equivs_
List of equivalent objects we’ve resolved so far. We use this to try to return different equivalent objects when multiple noun phrases refer to the same set of equivalents.
isGlobalScope
Is this a “global” scope? By default, the scope is local: it’s limited to what the actor can see, hear, etc. In some cases, the scope is broader, and extends beyond the senses; we call those cases global scope.
This is an advisory status only. The caller musn’t take this to mean that everything is in scope; objInScope() and getScopeList() must still be used to make the exact determination of what objects are in scope. However, some noun phrase productions might wish to know generally whether we’re in a local or global sort of scope, so that they can adjust their zeal at reducing ambiguity. In cases of global scope, we generally want to be more inclusive of possible matches than in local scopes, because we have much less of a basis to guess about what the player might mean.
isSubResolver
Are we a sub-phrase resolver? This should return true if we’re being used to resolve a sub-phrase of the main phrase.
issuer_
the issuing actor
scope_
The cached scope list, if we have one. Note that this is an internal implementation detail of the base class; subclasses can dispense with the cached scope list if they define their own objInScope() and getScopeList() overrides.
Note that any subclasses (including Actions) that make changes to this list MUST ensure that the result only contains unique entries. The library assumes in several places that there are no duplicate entries in the list; subtle problems can occur if the list contains any duplicates.
whichMessageObject
Get an indication of which object we’re resolving, for message generation purposes. By default, we’ll indicate direct object; this should be overridden for resolvers of indirect and other types of objects.
whichObject
the role played by this object, if any
Methods
allowAll ( )
Determine if “all” is allowed for the noun phrase we’re resolving. By default, we’ll just ask the action.
cacheScopeList ( )
Cache the scope list for this object. By default, we cache the standard physical scope list for our target actor.
Note that if a subclass uses completely different rules for determining scope, it need not store a scope_ list at all. The scope_ list is purely an implementation detail of the base Resolver class. A subclass can use whatever internal implementation it wants, as long as it overrides objInScope() and getScopeList() to return consistent results.
construct (action, issuingActor, targetActor)
no description available
filterAll (lst, whichObj, np)
Filter an ‘all’ list to remove things that don’t belong. We always remove the actor executing the command, as well as any objects explicitly marked as hidden from ‘all’ lists.
Returns a ResolveInfo list, with each entry marked with the MatchedAll flag.
filterAmbiguousEquivalents (lst, np)
Filter a list of ambiguous matches (‘lst’) for a noun phrase, to reduce each set of equivalent items to a single such item, if desired. If no equivalent reduction is desired for this type of resolver, this can simply return the original list.
‘np’ is the noun phrase production that we’re resolving. This is usually a subclass of NounPhraseProd.
filterAmbiguousNounPhrase (lst, requiredNum, np)
Filter an ambiguous list of objects (‘lst’) resolving to a noun phrase. If the objects in the list vary in the degree of suitability for the command, returns a list consisting only of the most suitable objects. If the objects are all equally suitable - or equally unsuitable - the whole list should be returned unchanged.
‘requiredNum’ is the number of objects required in the final list by the caller; if the result list is larger than this, the caller will consider the results ambiguous.
‘np’ is the noun phrase production that we’re resolving. This is usually a subclass of NounPhraseProd.
This routine does NOT perform any interactive disambiguation, but is merely a first attempt at reducing the number of matching objects by removing the obviously unsuitable ones.
For example, for an “open” command, if the list consists of one object that’s open and one object that’s currently closed, the result list should include only the closed one, since it is obvious that the one that’s already open does not need to be opened again. On the other hand, if the list consists only of open objects, they should all be returned, since they’re all equally unsuitable.
It is not necessary to reduce the list to a single entry; it is adequate merely to reduce the ambiguity by removing any items that are clearly less suitable than the survivors.
filterPluralPhrase (lst, np)
Filter a plural phrase to reduce the set to the logical subset, if possible. If there is no logical subset, simply return the original set.
‘np’ is the noun phrase we’re resolving; this is usually a subclass of PluralProd.
filterPossRank (lst, num)
Filter an ambiguous noun phrase list using the strength of possessive qualification, if any. If we have subsets at different possessive strengths, choose the strongest subset that has at least the required number of objects.
getAction ( )
get the action we’re resolving
getAll (np)
Get the “all” list - this is the list of objects that we should use when the object of the command is the special word “all”. We’ll ask the action to resolve ‘all’ for the direct object, since we are by default a direct object resolver.
getAllDefaults ( )
Get the list of potential default objects. This is simply the basic ‘all’ list, not filtered for exclusion with hideFromAll.
getDefaultObject (np)
Get the default object or objects for this phrase. Returns a list of ResolveInfo objects if a default is available, or nil if no default is available. This routine does not interact with the user; it should merely determine if the command implies a default strongly enough to assume it without asking the user.
By default, we ask the action for a default direct object. Resolver subclasses should override this as appropriate for the specific objects they’re used to resolve.
getPossessiveResolver ( )
Get the resolver for possessive phrases. By default, we return a standard possessive resolver. This can be overridden in contexts wher ethe possesive resolution context is special.
getPronounDefault (typ, np)
Get the default in-scope object list for a given pronoun. We’ll look for a unique object in scope that matches the desired pronoun, and return a ResolveInfo list if we find one. If there aren’t any objects in scope that match the pronoun, or multiple objects are in scope, there’s no default.
getQualifierResolver ( )
Get the resolver for qualifier phrases. By default, this simply returns myself, since the resolver for qualifiers is in most contexts the same as the main resolver.
This can be overridden in contexts where the qualifier resolver is different from the main resolver. In general, when a sub-resolver narrows the scope for resolving a phrase, such as an exclusion list or a disambiguation response, we will want to resolve qualifiers in the context of the main resolution scope rather than the narrowed scope.
getRawPronounAntecedent (typ)
Get the “raw” pronoun antecedent list for a given pronoun selector. This returns a list of objects matching the pronoun. The list is raw in that it is given as a list of game objects (not ResolveInfo objects), and it isn’t filtered for scope.
getReflexiveBinding (typ)
Get the binding for a reflexive third-person pronoun (himself, herself, itself, themselves). By default, the reflexive binding is the anaphoric binding from the action - that is, it refers back to the preceding noun phrase in a verb phrase with multiple noun slots (as in ASK BOB ABOUT HIMSELF: ‘himself’ refers back to ‘bob’, the previous noun phrase).
getScopeList ( )
Get the full list of objects in scope. By default, this simply returns our cached scope list.
For every object in the list that getScopeList() returns, objInScope() must return true. However, getScopeList() need not return *all* objects that are in scope as far as objInScope() is concerned - it can, but a subset of in-scope objects is sufficient.
The default implementation returns the complete set of in-scope objects by simply returning the cached scope list. This is the same scope list that the default objInScope() checks, which ensures that the two methods produce consistent results.
The reason that it’s okay for this method to return a subset of in-scope objects is that the result is only used to resolve “wildcard” phrases in input, and such phrases don’t have to expand to every possible object. Examples of wildcard phrases include ALL, missing phrases that need default objects, and locational phrases (“the vase on the table” - which isn’t superficially a wildcard, but implicitly contains one in the form of “considering only everything on the table”). It’s perfectly reasonable for the parser to expand a wildcard based on what’s actually in sight, in mind, or whatever’s appropriate. So, in cases where you define an especially expansive objInScope() - for example, a universal scope like the one TopicResolver uses - it’s usually fine to use the default definition of getScopeList(), which returns only the objects that are in the smaller physical scope.
getTargetActor ( )
get the target actor
matchName (obj, origTokens, adjustedTokens)
Match an object’s name. By default, we’ll call the object’s own matchName method with the given original and adjusted token lists. Subclasses can override this to call different match methods (such as matchNameDisambig).
objInScope (obj)
Determine if an object is in scope for the purposes of object resolution. By default, we’ll return true if the object is in our cached scope list - this ensures that we produce results that are consistent with getScopeList().
Some subclasses might want to override this method to decide on scope without reference to a cached scope list, for efficiency reasons. For example, if a command’s scope is the set of all objects, caching the full list would take a lot of memory; to save the memory, you could override cacheScopeList() to do nothing at all, and then override objInScope() to return true - this will report that every object is in scope without bothering to store a list of every object.
Be aware that if you override objInScope(), you should ensure that getScopeList() yields consistent results. In particular, objInScope() should return true for every object in the list returned by getScopeList() (although getScopeList() doesn’t necessarily have to return every object for which objInScope() is true).
resetResolver ( )
Reset the resolver - this can be called if we are to re-use the same resolver to resolve a list of noun phrases again.
resolvePronounAntecedent (typ, np, results, poss)
Resolve a pronoun antecedent, given a pronoun selector. This returns a list of ResolveInfo objects, for use in object resolution. ‘poss’ is true if this is a possessive pronoun (his, her, its, etc), nil if it’s an ordinary, non-possessive pronoun (him, her, it, etc).
resolveUnknownNounPhrase (tokList)
Resolve a noun phrase involving unknown words, if possible. If it is not possible to resolve such a phrase, return nil; otherwise, return a list of resolved objects. This routine does not interact with the user - “oops” prompting is handled separately.
‘tokList’ is the token list for the phrase, in the canonical format as returned from the tokenizer. Each element of ‘tokList’ is a sublist representing one token.
Note that this routine allows for specialized unknown word resolution separately from the more general matchName mechanism. The purpose of this method is to allow the specific type of resolver to deal with unknown words specially, rather than using the matchName mechanism. This routine is called as a last resort, only after the matchName mechanism fails to find any matches.
selectIndefinite (results, lst, requiredNumber)
Select a resolution for an indefinite noun phrase (“a coin”), given a list of possible matches. The matches will be given to us sorted from most likely to least likely, as done by filterAmbiguousNounPhrase().
By default, we simply select the first ‘n’ items from the list (which are the most likely matches), because in most contexts, an indefinite noun phrase means that we should arbitrarily select any matching object. This can be overridden for contexts in which indefinite noun phrases must be handled differently.
withGlobals (func)
Execute a callback function in the global context of our actor and action - we’ll set gActor and gAction to our own stored actor and action values, then call the callback, then restore the old globals.
TADS 3 Library Manual
Generated on 5/16/2013 from TADS version 3.1.3