Package opennlp.tools.tokenize.lattice
Class DoubleArrayLexicon
java.lang.Object
opennlp.tools.tokenize.lattice.DoubleArrayLexicon
The lexicon as a double-array trie: one transition is one array read and one
comparison. Characters are recoded into dense labels ordered by descending
frequency before the array is built, which keeps the array compact; a character
absent from the lexicon misses in the recode table before the array is consulted.
The layout is the classic base/check pair: from state s, label
c leads to t = base[s] + c exactly when check[t] == s.
Label 0 terminates a surface and leads to a state. Its negative base
encodes the index of the surface's entry list.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classBuilds the trie from sorted surface ranges. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDoubleArrayLexicon(int[] base, int[] check, int[] codeOf, List<MecabDictionary.WordEntry>[] values) Creates a lexicon from completed double-array tables and entry lists. -
Method Summary
Modifier and TypeMethodDescription(package private) static DoubleArrayLexiconbuild(Map<String, List<MecabDictionary.WordEntry>> lexicon) Builds the trie from the surface-keyed lexicon.(package private) voidprefixMatches(String text, int from, int to, MecabDictionary.PrefixMatchConsumer consumer) Reports every surface starting at a text position, walking the array once.
-
Field Details
-
base
private final int[] base -
check
private final int[] check -
codeOf
private final int[] codeOf -
values
-
-
Constructor Details
-
DoubleArrayLexicon
private DoubleArrayLexicon(int[] base, int[] check, int[] codeOf, List<MecabDictionary.WordEntry>[] values) Creates a lexicon from completed double-array tables and entry lists.- Parameters:
base- The transition offsets.check- The parent state for each occupied index.codeOf- The dense label for each UTF-16 character.values- The entries for each surface.
-
-
Method Details
-
build
Builds the trie from the surface-keyed lexicon.- Parameters:
lexicon- The entries keyed by surface form.- Returns:
- The built trie. Not
null.
-
prefixMatches
Reports every surface starting at a text position, walking the array once.- Parameters:
text- The text being segmented.from- The position surfaces must start at.to- The exclusive end of the searchable stretch.consumer- Receives each match length with its entries.
-