CommandRanking class | parser.t[6086]

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` | `parser.t[6371]`

an actor is specified

`allExcludedCount` | `parser.t[6344]`

number of "all" or "any" lists totally excluded by "but"

`allowActionRemapping` | `parser.t[6701]`

don't allow action remapping while ranking

`ambigCount` | `parser.t[6365]`

number of ambiguous noun phrases

`commandCount` | `parser.t[6368]`

number of subcommands in the command

`emptyButCount` | `parser.t[6341]`

number of empty "but" lists

`endAdjCount` | `parser.t[6353]`

number of phrases ending in adjectives

`indefiniteCount` | `parser.t[6356]`

number of phrases with indefinite noun phrase structure

`inSingleObjSlot` | `parser.t[6650]`

no description available

`insufficientCount` | `parser.t[6335]`

number of phrases requiring quantity higher than can be fulfilled

`inTopicSlot` | `parser.t[6654]`

no description available

`listForSingle` | `parser.t[6338]`

number of noun lists in single-noun slots

`literalLength` | `parser.t[6377]`

total character length of literal text phrases

`match` | `parser.t[6303]`

the match tree I'm ranking

`miscWordListCount` | `parser.t[6359]`

number of miscellaneous word lists as noun phrases

`missingCount` | `parser.t[6347]`

missing phrases (structurally omitted, as in "put book")

`nonMatchCount` | `parser.t[6325]`

number of noun phrases matching nothing in scope

`nonMatchPossCount` | `parser.t[6332]`

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` | `parser.t[6319]`

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` | `parser.t[6350]`

number of truncated plurals

`pronounCount` | `parser.t[6380]`

number of pronoun phrases

`rankingCriteria` | `parser.t[6279]`

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` | `parser.t[6306]`

the number of tokens my match tree consumes

`truncCount` | `parser.t[6362]`

number of truncated words overall

`unknownWordCount` | `parser.t[6374]`

unknown words

`unwantedPluralCount` | `parser.t[6386]`

number of plural phrases encountered in single-object slots

`vocabNonMatchCount` | `parser.t[6322]`

number of noun phrases matching nothing anywhere in the game

`weaknessLevel` | `parser.t[6383]`

weakness level (for noteWeakPhrasing)

Methods

`allNotAllowed ( )` | `parser.t[6419]`

note that we have an unmatched possessive-qualified noun phrase

`ambiguousNounPhrase (keeper, asker, txt, matchList, fullMatchList, scopeList, requiredNum, resolver)` | `parser.t[6490]`

treat this as any other noun phrase that matches nothing

`askMissingObject (asker, resolver, responseProd)` | `parser.t[6553]`

count the missing object phrase

`beginSingleObjSlot ( )` | `parser.t[6648]`

if this object was matched with a truncated plural, note it

`beginTopicSlot ( )` | `parser.t[6652]`

no description available

`calcRanking (resolveArguments)` | `parser.t[6133]`

calculate my ranking

`compareRanking (other)` | `parser.t[6160]`

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)` | `parser.t[6123]`

create a new entry

`emptyNounPhrase (resolver)` | `parser.t[6569]`

add the length of this literal to the total literal length

`endSingleObjSlot ( )` | `parser.t[6649]`

no description available

`endTopicSlot ( )` | `parser.t[6653]`

no description available

`getImpliedObject (np, resolver)` | `parser.t[6546]`

return the results

`incCommandCount ( )` | `parser.t[6669]`

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)` | `parser.t[6582]`

treat this as a non-matching noun phrase

`noMatch (action, txt)` | `parser.t[6406]`

note the unknown phrase

`noMatchForAll ( )` | `parser.t[6425]`

treat this as a non-matching noun phrase

`noMatchForAllBut ( )` | `parser.t[6437]`

note it

`noMatchForListBut ( )` | `parser.t[6443]`

count the total exclusion

`noMatchForLocation (loc, txt)` | `parser.t[6473]`

treat this as any other noun phrase that matches nothing

`noMatchForPossessive (owner, txt)` | `parser.t[6467]`

treat this as any other noun phrase that matches nothing

`noMatchForPronoun (typ, txt)` | `parser.t[6449]`

treat this as any other noun phrase that matches nothing

`noMatchPossessive (action, txt)` | `parser.t[6412]`

note that we have a noun phrase that matches nothing

`noteActorSpecified ( )` | `parser.t[6675]`

increase our subcommand counter

`noteAdjEnding ( )` | `parser.t[6602]`

ignore this for now - we might get a unique object via disambiguation during the execution phase

`noteBadPrep ( )` | `parser.t[6479]`

treat this as any other noun phrase that matches nothing

`noteEmptyBut ( )` | `parser.t[6431]`

treat this as any other noun phrase that matches nothing

`noteIndefinite ( )` | `parser.t[6608]`

count it

`noteLiteral (txt)` | `parser.t[6563]`

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)` | `parser.t[6629]`

note the presence of a pronoun

`noteMiscWordList (txt)` | `parser.t[6614]`

count it

`noteNounSlots (cnt)` | `parser.t[6681]`

note it

`notePlural ( )` | `parser.t[6656]`

no description available

`notePronoun ( )` | `parser.t[6623]`

count this as a literal as well

`noteWeakPhrasing (level)` | `parser.t[6694]`

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)` | `parser.t[6484]`

don't do anything at this point

`noVocabMatch (action, txt)` | `parser.t[6400]`

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)` | `parser.t[6455]`

treat this as any other noun phrase that matches nothing

`singleObjectRequired (txt)` | `parser.t[6588]`

treat this as a non-matching noun phrase

`sortByRanking (lst, [resolveArguments])` | `parser.t[6095]`

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)` | `parser.t[6594]`

treat this as a non-matching noun phrase

`unknownNounPhrase (match, resolver)` | `parser.t[6516]`

return the abbreviated list

`wrongReflexive (typ, txt)` | `parser.t[6461]`

treat this as any other noun phrase that matches nothing

`zeroQuantity (txt)` | `parser.t[6576]`

treat this as a non-matching noun phrase

TADS 3 Library Manual
Generated on 8/21/2012 from TADS version 3.1.2