Constructs a Scope
.
typically a reference to the dictionary this scope is contained within.
an array of patterns to initially add to this scope.
Given an word, returns the final node which matches the complete word. null otherwise.
Given an input sequence of words, a starting node, and a dictionary, finds all valid matching paths that the input satisfies.
If we have a starting node which yields the following sub-trie,
t - r - i - e
\
e - e
and input "tr", the returned node will be "r".
With a more complex starting trie,
null - a - b - c - - d (1)
\
<X> - - d (2)
<X>: null - a - b - c
\
<Y>
<Y>: null - a - b - c - - d (3)
given "abc d", it wll return the "d" nodes labeled (1), (2), (3)
Since patterns can span multiple levels of nested contexts, we need to return not only the matched words (partially matched on completed words), but also the remainder of the match. This way, we can check for matches in parent contexts in case a pattern satisfies a match over an arbitrary number of contextual levels.
Given a sequence of input tokens, returns an array of suggested completions.
a sequence of input tokens.
how many tokens to resolve in lookups which occur immediately after input. See lookahead.
Generated using TypeDoc
A
Scope
is the top-level node of a Phrase Trie -- a trie of (trie)s which allows not only matching next characters, but also next words. This class exposes methods for adding, removing, and suggesting patterns.As a technical note, a
Scope
's value isnull
, thus all patterns within a scope are accessible through theScope.next.word
orScope.next.lookup
.