Constructs a Dictionary
.
sets lookahead parameter.
Configures how many consecutive lookups to resolve given a suggestion with a lookup term which immediately follows the input pattern.
For example, if there exists the following pattern
// assume the scopes for the 'color', 'size', & 'shape' scope groups have been defined.
one two <color> <size> <shape>
then, given an input of ['one', 'two']
& lookahead=2
, the resulting suggestions would be,
one two green big <shape>
one two red big <shape>
one two green small <shape>
...
A map of scope names to corresponding scopes.
Adds patterns to an existing scope.
an existing scope name.
array of patterns to add.
Removes patterns from an existing scope.
an existing scope name.
array of patterns to remove.
Generates suggestions from specified scopes given an array of input tokens.
This method expects that the input tokens have already been tokenized by the calling code. In particular, multi-word inputs, which are expected to be matched against phrase-based patterns which have been added to a scope, must be broken up into a array of words (rather than just an raw string with words separated by spaces).
a single input word token or array of input word tokens.
Generated using TypeDoc
A
Dictionary
is used to define, add/remove patterns to/from, and generate suggestions from suggestion scopes. As someone using this library, theDictionary
class will likely be the primary interface between your code and the functionalityautosuggestion
has to offer.Generally speaking, a
Dictionary
is a collection of named [[Trie|scopes]] containing patterns (words or phrases) which can be easily matched with partially completed input patterns 1. For example, if we want to generate suggestions based on a list of colors, we cannow, we can generate suggestions given input,
If we don't know all the patterns for a scope upfront, we can dynamically add,
or remove,
[1] Each named scope is a special type of trie indexed by a string-valued name. What makes this type of trie special is that each node not only points to the set of next character candidates, but also points to the set of next word candidates. This makes it, essentially, a trie of tries allowing us to perform phrase-based matches in addition to word-based matches.