NounPhraseWithVocabclassparser.t[3578]

Noun phrase with vocabulary resolution. This is a base class for the various noun phrases that match adjective, noun, and plural tokens. This class provides dictionary resolution of a vocabulary word into a list of objects.

In non-declined languages such as English, the parts of speech of our words are usually simply 'adjective' and 'noun'. A language "declines" its noun phrases if the words in a noun phrase have different forms that depend on the function of the noun phrase in a sentence; for example, in German, adjectives take suffixes that depend upon the gender of the noun being modified and the function of the noun phrase in the sentence (subject, direct object, etc). In a declined language, it might be desirable to use separate parts of speech for separate declined adjective and noun forms.

class NounPhraseWithVocab :   NounPhraseProd

Superclass Tree   (in declaration order)

NounPhraseWithVocab
        NounPhraseProd
                BasicProd
                        object

Subclass Tree  

NounPhraseWithVocab
        adjPhrase(adjAdj)
        AdjPhraseWithVocab
                adjPhrase(adj)
                adjWord(adj)
                adjWord(adjAbbr)
                adjWord(adjApostS)
                literalAdjPhrase(literalAdj)
                literalAdjPhrase(number)
                literalAdjPhrase(string)
        compoundNounPhrase(of)
        compoundNounPhrase(simple)
        compoundPluralPhrase(of)
        compoundPluralPhrase(simple)
        miscWordList(list)
        miscWordList(wordOrNumber)
        NounWordProd
                nounWord(noun)
                nounWord(nounAbbr)
        simpleNounPhrase(adj)
        simpleNounPhrase(adjAndOne)
        simpleNounPhrase(adjNP)
        simpleNounPhrase(empty)
        simpleNounPhrase(misc)
        simpleNounPhrase(noun)
        simpleNounPhrase(nounAndNumber)
        simpleNounPhrase(number)
        simpleNounPhrase(numberAndNoun)
        simplePluralPhrase(adjAndOnes)
        simplePluralPhrase(empty)
        simplePluralPhrase(misc)
        simplePluralPhrase(plural)
        simplePluralPhrase(poundNum)

Global Objects  

(none)

Summary of Properties  

Inherited from NounPhraseProd :
filterForCollectives 

Inherited from BasicProd :
firstTokenIndex  isSpecialResponseMatch  lastTokenIndex 

Summary of Methods  

combineWordMatches  combineWordMatchItems  dictMatchIsExact  dictMatchIsStronger  filterDictMatches  getAdjustedTokens  getVocabMatchList  getWordMatches  inScopeMatches  intersectWordMatches  resolveNouns  resolveNounsMatchName 

Inherited from NounPhraseProd :
filterTruncations  getVerifyKeepers 

Inherited from BasicProd :
canResolveTo  getOrigText  getOrigTokenList  setOrigTokenList 

Properties  

(none)

Methods  

combineWordMatches (aLst, bLst)parser.t[3607]

Combine two word match lists. This simply adds each entry from the second list that doesn't already have a corresponding entry in the first list, returning the combined list.

combineWordMatchItems (a, b)parser.t[3656]
Combine the given word match entries. We'll merge the flags of the two entries to produce a single merged entry in 'a'.

dictMatchIsExact (flags)parser.t[3769]
Check a dictionary match's string comparator flags to see if the match is "exact." The exact meaning of "exact" is dependent on the language's lexical rules; this generic base version considers a match to be exact if it doesn't have any string comparator flags other than the base "matched" flag and the case-fold flag. This should be suitable for most languages, as (1) case folding usually doesn't improve match strength, and (2) any additional comparator flags usually indicate some kind of inexact match status.

A language that depends on upper/lower case as a marker of match strength will need to override this to consider the case-fold flag as significant in determining match exactness. In addition, a language that uses additional string comparator flags to indicate better (rather than worse) matches will have to override this to require the presence of those flags.

dictMatchIsStronger (flags1, flags2)parser.t[3795]
Compare two dictionary matches for the same object and determine if the first one is stronger than the second. Both are for the same object; the only difference is the string comparator flags.

Language modules might need to override this to supplement the filtering with their own rules. This generic base version considers truncation: an untruncated match is stronger than a truncated match. Non-English languages might want to consider other lexical factors in the match strength, such as whether we matched the exact accented characters or approximated with unaccented equivalents - this information will, of course, need to be coordinated with the dictionary's string comparator, and reflected in the comparator match flags. It's the comparator match flags that we're looking at here.

filterDictMatches (lst)parser.t[3702]
Filter a dictionary match list. This is called to clean up the raw match list returned from looking up a vocabulary word in the dictionary.

The main purpose of this routine is to eliminate unwanted redundancy from the dictionary matches; in particular, the dictionary might have multiple matches for a given word at a given object, due to truncation, upper/lower folding, accent removal, and so on. In general, we want to keep only the single strongest match from the dictionary for a given word matching a given object.

The meaning of "stronger" and "exact" matches is language-dependent, so we abstract these with the separate methods dictMatchIsExact() and dictMatchIsStronger().

Keep in mind that the raw dictionary match list has alternating entries: object, comparator flags, object, comparator flags, etc. The return list should be in the same format.

getAdjustedTokens ( )parser.t[4005]
Each subclass must override getAdjustedTokens() to provide the appropriate set of tokens used to match the object. This is usually simply the original set of tokens, but in some cases it may differ; for example, spelled-out numbers normally adjust to the numeral form of the number.

For each adjusted token, the list must have two entries: the first is a string giving the token text, and the second is the property giving the part of speech for the token.

getVocabMatchList (resolver, results, extraFlags)parser.t[4014]
Get the vocabulary match list. This is simply the set of objects that match all of the words in the noun phrase. Each rule subclass must override this to return an appropriate list. Note that subclasses should use getWordMatches() and intersectWordMatches() to build the list.

getWordMatches (tok, partOfSpeech, resolver, flags, truncFlags)parser.t[3585]
Get a list of the matches in the main dictionary for the given token as the given part of speech (&noun, &adjective, &plural, or others as appropriate for the local language) that are in scope according to the resolver.

inScopeMatches (dictionaryMatches, flags, truncFlags, resolver)parser.t[3832]
Given a list of dictionary matches to a given word, construct a list of ResolveInfo objects for the matches that are in scope. For regular resolution, "in scope" means the resolver thinks the object is in scope.

intersectWordMatches (tok, partOfSpeech, resolver, flags, truncFlags, lst)parser.t[3811]
Get a list of the matches in the main dictionary for the given token, intersecting the resulting list with the given list.

resolveNouns (resolver, results)parser.t[3882]
Resolve the objects.

resolveNounsMatchName (results, resolver, matchList)parser.t[3912]
Run a set of resolved objects through matchName() or a similar routine. Returns the filtered results.

TADS 3 Library Manual
Generated on 5/16/2013 from TADS version 3.1.3