Package opennlp.tools.tokenize.lattice
Class CategoryTable.Builder
java.lang.Object
opennlp.tools.tokenize.lattice.CategoryTable.Builder
- Enclosing class:
CategoryTable
Collects
char.def mappings in file order and builds a
CategoryTable, giving a later mapping precedence over an earlier one that
covers the same code point, which is what direct indexing does for the BMP.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordOne mapping line retained for validation after all categories have been read. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) CategoryTablebuild(Map<String, MecabDictionary.Category> categories) Builds the lookup table from the recorded mappings.private String[]lastCovering(int codePoint) Finds the category of the last recorded range covering a code point.(package private) voidRecords one inclusive code point range's categories.private CategoryTable.CategoryAssignmentresolve(String[] names, Map<String, MecabDictionary.Category> categories, Map<String[], CategoryTable.CategoryAssignment> resolvedAssignments, int codePoint) Resolves mapped category names using the defined categories.
-
Field Details
-
bmp
-
bounds
-
names
-
mappings
-
-
Constructor Details
-
Builder
Builder()
-
-
Method Details
-
map
Records one inclusive code point range's categories.- Parameters:
from- The first code point of the range.to- The last code point of the range, inclusive.categories- The category names to give the range, primary first. Must not benullor empty.
-
build
Builds the lookup table from the recorded mappings.- Parameters:
categories- The categories thechar.defcategory section defined, keyed by name.- Returns:
- The table. Not
null. - Throws:
InvalidFormatException- Thrown if a mapping names a category that was not defined.
-
resolve
private CategoryTable.CategoryAssignment resolve(String[] names, Map<String, MecabDictionary.Category> categories, Map<String[], throws InvalidFormatExceptionCategoryTable.CategoryAssignment> resolvedAssignments, int codePoint) Resolves mapped category names using the defined categories. A mapping to an undefined category fails at load and names the offending code point.- Parameters:
names- The category names on a mapping line, primary first.categories- The defined categories, keyed by name.resolvedAssignments- Previously resolved mapping lines, indexed by their shared category-name arrays.codePoint- A code point the mapping covers, for the error message.- Returns:
- The resolved assignment. Not
null. - Throws:
InvalidFormatException- Thrown if any named category was not defined.
-
lastCovering
Finds the category of the last recorded range covering a code point.- Parameters:
codePoint- The code point to look up.- Returns:
- The category names, or
nullwhen no stored range covers it.
-