Package opennlp.tools.tokenize.lattice
Class DoubleArrayLexicon.Builder
java.lang.Object
opennlp.tools.tokenize.lattice.DoubleArrayLexicon.Builder
- Enclosing class:
DoubleArrayLexicon
Builds the trie from sorted surface ranges. Each node places children at a common
free base, and a moving watermark makes that search near-linear over real
lexicons. The traversal uses an explicit stack so a long surface cannot exhaust
the thread stack.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordA surface range with children waiting to be placed. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidensureCapacity(int slot) Grows the base and check arrays until a slot is addressable.private intfindBase(int[] labels, int labelCount) Finds the lowest base at which all labels use free indices.private voidinsert(int left, int right, int depth, int state) Places one trie node and all its descendants, using an explicit work stack instead of recursion.
-
Field Details
-
ROOT
private static final int ROOT- See Also:
-
EMPTY
private static final int EMPTY- See Also:
-
surfaces
-
codeOf
private final int[] codeOf -
base
private int[] base -
check
private int[] check -
high
private int high -
watermark
private int watermark -
valueIndex
private int valueIndex
-
-
Constructor Details
-
Builder
Initializes storage for the sorted surfaces and their dense character codes.- Parameters:
surfaces- The sorted surface forms.codeOf- The dense label for each UTF-16 character.
-
-
Method Details
-
insert
private void insert(int left, int right, int depth, int state) Places one trie node and all its descendants, using an explicit work stack instead of recursion.- Parameters:
left- The first surface of the node's range.right- The exclusive end of the node's surface range.depth- The character depth of the node.state- The node's own slot.
-
findBase
private int findBase(int[] labels, int labelCount) Finds the lowest base at which all labels use free indices. Labels follow surface-character order, not numeric order, so this method computes their smallest and largest values first.- Parameters:
labels- The child labels to place.labelCount- How many leading elements oflabelsare in use.- Returns:
- The base offset every label fits at.
-
ensureCapacity
private void ensureCapacity(int slot) Grows the base and check arrays until a slot is addressable.- Parameters:
slot- The highest slot index that has to be writable.
-