Class CategoryTable.Builder

java.lang.Object
opennlp.tools.tokenize.lattice.CategoryTable.Builder
Enclosing class:
CategoryTable

static final class CategoryTable.Builder extends Object
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.
  • Field Details

  • Constructor Details

    • Builder

      Builder()
  • Method Details

    • map

      void map(int from, int to, String[] categories)
      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 be null or empty.
    • build

      Builds the lookup table from the recorded mappings.
      Parameters:
      categories - The categories the char.def category 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[],CategoryTable.CategoryAssignment> resolvedAssignments, int codePoint) throws InvalidFormatException
      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

      private String[] lastCovering(int codePoint)
      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 null when no stored range covers it.