Enum Class WordType

java.lang.Object
java.lang.Enum<WordType>
opennlp.tools.tokenize.uax29.WordType
All Implemented Interfaces:
Serializable, Comparable<WordType>, Constable

public enum WordType extends Enum<WordType>
The category of a word token. ALPHANUMERIC and NUMERIC cover letter and digit words; the remaining categories identify scripts and emoji that benefit from script-specific handling. The boundaries themselves follow the Unicode release shipped with WordSegmenter.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    A token that contains at least one letter (optionally mixed with digits and connectors).
    An emoji, emoji sequence, or regional-indicator flag.
    A Hangul token.
    A Hiragana token.
    A token containing a Han ideograph (one ideograph per token under UAX #29 segmentation).
    A Katakana token.
    A token made up entirely of digits and numeric connectors.
    A token in a Southeast Asian script that requires dictionary segmentation (Thai, Lao, ...).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final byte[]
     
    private static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static byte[]
     
    (package private) static WordType
    of(CharSequence text, int start, int end)
    Classifies the code points of text over [start, end) as a word token type, or null when the range is not a word (pure whitespace, punctuation, or symbols).
    private static WordType
    scriptType(int codePoint)
     
    static WordType
    Returns the enum constant of this class with the specified name.
    static WordType[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ALPHANUMERIC

      public static final WordType ALPHANUMERIC
      A token that contains at least one letter (optionally mixed with digits and connectors).
    • NUMERIC

      public static final WordType NUMERIC
      A token made up entirely of digits and numeric connectors.
    • IDEOGRAPHIC

      public static final WordType IDEOGRAPHIC
      A token containing a Han ideograph (one ideograph per token under UAX #29 segmentation).
    • HIRAGANA

      public static final WordType HIRAGANA
      A Hiragana token.
    • KATAKANA

      public static final WordType KATAKANA
      A Katakana token.
    • HANGUL

      public static final WordType HANGUL
      A Hangul token.
    • SOUTHEAST_ASIAN

      public static final WordType SOUTHEAST_ASIAN
      A token in a Southeast Asian script that requires dictionary segmentation (Thai, Lao, ...).
    • EMOJI

      public static final WordType EMOJI
      An emoji, emoji sequence, or regional-indicator flag.
  • Field Details

    • LOWEST_SCRIPT_CODE_POINT

      private static final int LOWEST_SCRIPT_CODE_POINT
      See Also:
    • ASCII_KIND

      private static final byte[] ASCII_KIND
  • Constructor Details

    • WordType

      private WordType()
  • Method Details

    • values

      public static WordType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static WordType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • buildAsciiKind

      private static byte[] buildAsciiKind()
    • of

      static WordType of(CharSequence text, int start, int end)
      Classifies the code points of text over [start, end) as a word token type, or null when the range is not a word (pure whitespace, punctuation, or symbols). Emoji win over scripts, scripts over the generic alphanumeric/numeric split. The script category is taken from the first script code point in the range; UAX #29 word segments are single-script in practice, so for an unusual mixed-script run this reports the leading script, not a per-character determination.
      Parameters:
      text - The text containing the token.
      start - The inclusive start character offset.
      end - The exclusive end character offset.
      Returns:
      The token type, or null if the range is not a word.
      Throws:
      IllegalStateException - Thrown if the bundled Extended_Pictographic data resource is missing (raised transitively through ExtendedPictographic).
      UncheckedIOException - Thrown if that resource cannot be read.
    • scriptType

      private static WordType scriptType(int codePoint)