CommandRankingclass
Production match ranking object. We create one of these objects for each match tree that we wish to rank.
This class is generally not instantiated by client code - instead, clients use the sortByRanking() class method to rank a list of production matches.
class
CommandRanking
:
ResolveResults
Superclass Tree (in declaration order)
CommandRanking
ResolveResults
` object`
Subclass Tree
CommandRanking
DisambigRanking
MissingObjectRanking
OopsResults
Global Objects
(none)
Summary of Properties
actorSpecifiedCount
allExcludedCount
allowActionRemapping
ambigCount
commandCount
emptyButCount
endAdjCount
indefiniteCount
inSingleObjSlot
insufficientCount
inTopicSlot
listForSingle
literalLength
match
miscWordListCount
missingCount
nonMatchCount
nonMatchPossCount
nounSlotCount
pluralTruncCount
pronounCount
rankingCriteria
tokCount
truncCount
unknownWordCount
unwantedPluralCount
vocabNonMatchCount
weaknessLevel
Summary of Methods
allNotAllowed
ambiguousNounPhrase
askMissingObject
beginSingleObjSlot
beginTopicSlot
calcRanking
compareRanking
construct
emptyNounPhrase
endSingleObjSlot
endTopicSlot
getImpliedObject
incCommandCount
insufficientQuantity
noMatch
noMatchForAll
noMatchForAllBut
noMatchForListBut
noMatchForLocation
noMatchForPossessive
noMatchForPronoun
noMatchPossessive
noteActorSpecified
noteAdjEnding
noteBadPrep
noteEmptyBut
noteIndefinite
noteLiteral
noteMatches
noteMiscWordList
noteNounSlots
notePlural
notePronoun
noteWeakPhrasing
nothingInLocation
noVocabMatch
reflexiveNotAllowed
singleObjectRequired
sortByRanking
uniqueObjectRequired
unknownNounPhrase
wrongReflexive
zeroQuantity
Properties
actorSpecifiedCount
an actor is specified
allExcludedCount
number of “all” or “any” lists totally excluded by “but”
allowActionRemapping
don’t allow action remapping while ranking
ambigCount
number of ambiguous noun phrases
commandCount
number of subcommands in the command
emptyButCount
number of empty “but” lists
endAdjCount
number of phrases ending in adjectives
indefiniteCount
number of phrases with indefinite noun phrase structure
inSingleObjSlot
no description available
insufficientCount
number of phrases requiring quantity higher than can be fulfilled
inTopicSlot
no description available
listForSingle
number of noun lists in single-noun slots
literalLength
total character length of literal text phrases
match
the match tree I’m ranking
miscWordListCount
number of miscellaneous word lists as noun phrases
missingCount
missing phrases (structurally omitted, as in “put book”)
nonMatchCount
number of noun phrases matching nothing in scope
nonMatchPossCount
Number of possessive-qualified noun phrases matching nothing in scope. For example, “bob’s desk” when there’s no desk in scope (Bob’s or otherwise).
nounSlotCount
The number of structural “noun phrase slots” in the verb. An intransitive verb has no noun phrase slots; a transitive verb with a direct object has one; a verb with a direct and indirect object has two slots.
pluralTruncCount
number of truncated plurals
pronounCount
number of pronoun phrases
rankingCriteria
Our list of ranking criteria. This is a list of CommandRankingCriterion objects. The list is given in order of importance: the first criterion is the most important, so if it can discriminate the two match trees, we use its result; if the first criterion can’t tell any difference, then we move on to the second criterion; and so on through the list.
The most important thing is whether or not we have irresolvable noun phrases (vocabNonMatchCount). If one of us has a noun phrase that refers to nothing anywhere in the game, it’s not as good as a phrase that at least matches something somewhere.
Next, if one of us has noun phrases that cannot be resolved to something in scope (nonMatchCount), and the other can successfully resolve its noun phrases, the one that can resolve the phrases is preferred.
Next, check for insufficient numbers of matches to counted phrases (insufficientCount).
Next, check for noun lists in single-noun-only slots (listForSingle).
Next, if we have an empty “but” list in one but not the other, take the one with the non-empty “but” list (emptyButCount). We prefer a non-empty “but” list with an empty “all” even to a non-empty “all” list with an empty “but”, because in the latter case we probably failed to exclude anything because we misinterpreted the noun phrase to be excluded.
Next, if we have an empty “all” or “any” phrase due to “but” exclusion, take the one that’s not empty (allExcludedCount).
Next, prefer a command that addresses an actor (actorSpecifiedCount) - if the actor name looks like a command (we have someone named “Open Bob,” maybe?), we’d prefer to interpret the name appearing as a command prefix as an actor name.
Next, prefer no unstructured word lists as noun phrases (miscWordList phrases) (miscWordListCount).
Next, prefer interpretations that treat less text as uninterpreted literal text. By “less text,” we simply mean that one has a shorter string treated as a literal than the other.
Prefer no indefinite noun phrases (indefiniteCount).
Prefer no truncated plurals (pluralTruncCount).
Prefer no noun phrases ending in adjectives (endAdjCount).
Prefer no truncated words of any kind (truncCount).
Prefer fewer pronouns. If we have an interpretation that matches a word to explicit vocabulary, take it over matching a word as a pronoun: if a word is given explicitly as vocabulary for an object, use it if possible.
Prefer no missing phrases (missingCount).
Prefer the one with fewer subcommands - if one has fewer subcommands than the other, it means that we were able to interpret ambiguous conjunctions (such as “and”) as noun phrase conjunctions rather than as command conjunctions; since we know by now that we both either have or don’t have unresolved noun phrases, we’d rather take the interpretation that gives us noun phrases than the one that involves more separate commands.
Prefer the tree that matches more tokens.
Prefer the one with more structural noun phrases in the verb. For example, if we have one interpretation that’s DETACH (X FROM Y) (where X FROM Y is a ‘locational’ phrase that we treat as the direct object), and one that’s DETACH X FROM Y (where X is the direct object and Y is in the indirect object), prefer the latter, because it has both direct and indirect object phrases, whereas the former has only a direct object phrase. English speakers almost always try to put prepositions into a structural role in the verb phrase like this when they could be either in the verb phrase or part of a noun phrase.
If all else fails, prefer the one that is initially less ambiguous. Ambiguity is a weak test at this point, since we might end up narrowing things down through automatic “logicalness” tests later, but it’s slightly better to have the match be less ambiguous now, all other things being equal.
tokCount
the number of tokens my match tree consumes
truncCount
number of truncated words overall
unknownWordCount
unknown words
unwantedPluralCount
number of plural phrases encountered in single-object slots
vocabNonMatchCount
number of noun phrases matching nothing anywhere in the game
weaknessLevel
weakness level (for noteWeakPhrasing)
Methods
allNotAllowed ( )
note that we have an unmatched possessive-qualified noun phrase
ambiguousNounPhrase (keeper, asker, txt, matchList, fullMatchList, scopeList, requiredNum, resolver)
treat this as any other noun phrase that matches nothing
askMissingObject (asker, resolver, responseProd)
count the missing object phrase
beginSingleObjSlot ( )
if this object was matched with a truncated plural, note it
beginTopicSlot ( )
no description available
calcRanking (resolveArguments)
calculate my ranking
compareRanking (other)
Compare two production list entries for ranking purposes. Returns a negative number if this one ranks worse than the other, 0 if they have the same ranking, or a positive number if this one ranks better than the other one.
This routine is designed to run entirely off of our rankingCriteria property. In most cases, subclasses should be able to customize the ranking system simply by overriding the rankingCriteria property to provide a customized list of criteria objects.
construct (match)
create a new entry
emptyNounPhrase (resolver)
add the length of this literal to the total literal length
endSingleObjSlot ( )
no description available
endTopicSlot ( )
no description available
getImpliedObject (np, resolver)
return the results
incCommandCount ( )
If we’re resolving a single-object slot, we want to avoid plurals, since they could resolve to multiple objects as though we’d typed a list of objects here. This isn’t a problem for topics, though, since a topic slot isn’t iterated for execution.
insufficientQuantity (txt, matchList, requiredNum)
treat this as a non-matching noun phrase
noMatch (action, txt)
note the unknown phrase
noMatchForAll ( )
treat this as a non-matching noun phrase
noMatchForAllBut ( )
note it
noMatchForListBut ( )
count the total exclusion
noMatchForLocation (loc, txt)
treat this as any other noun phrase that matches nothing
noMatchForPossessive (owner, txt)
treat this as any other noun phrase that matches nothing
noMatchForPronoun (typ, txt)
treat this as any other noun phrase that matches nothing
noMatchPossessive (action, txt)
note that we have a noun phrase that matches nothing
noteActorSpecified ( )
increase our subcommand counter
noteAdjEnding ( )
ignore this for now - we might get a unique object via disambiguation during the execution phase
noteBadPrep ( )
treat this as any other noun phrase that matches nothing
noteEmptyBut ( )
treat this as any other noun phrase that matches nothing
noteIndefinite ( )
count it
noteLiteral (txt)
no need to do anything here - we’ll count the missing object in getImpliedObject, and we don’t want to ask for anything interactively at this point
noteMatches (matchList)
note the presence of a pronoun
noteMiscWordList (txt)
count it
noteNounSlots (cnt)
note it
notePlural ( )
no description available
notePronoun ( )
count this as a literal as well
noteWeakPhrasing (level)
If this is the first noun slot count we’ve received, remember it. If we already have a count, ignore the new one - we only want to consider the first verb phrase if there are multiple verb phrases, since we’ll reconsider the next verb phrase when we’re ready to execute it.
nothingInLocation (txt)
don’t do anything at this point
noVocabMatch (action, txt)
ResolveResults implementation. We use this results receiver when we’re comparing the semantic strengths of multiple structural matches, so we merely note each error condition without showing any message to the user or asking the user for any input. Once we’ve ranked all of the matches, we’ll choose the one with the best attributes and then resolve it for real, at which point if we chose one with any errors, we’ll finally get around to showing the errors to the user.
reflexiveNotAllowed (typ, txt)
treat this as any other noun phrase that matches nothing
singleObjectRequired (txt)
treat this as a non-matching noun phrase
sortByRanking (lst, [resolveArguments])
Sort a list of productions, as returned from GrammarProd.parseTokens(), in descending order of command strength. We return a list of CommandRanking objects whose first element is the best command interpretation.
Note that this can be used as a class-level method.
uniqueObjectRequired (txt, matchList)
treat this as a non-matching noun phrase
unknownNounPhrase (match, resolver)
return the abbreviated list
wrongReflexive (typ, txt)
treat this as any other noun phrase that matches nothing
zeroQuantity (txt)
treat this as a non-matching noun phrase
TADS 3 Library Manual
Generated on 5/16/2013 from TADS version 3.1.3