Class ThaiTokenizer

All Implemented Interfaces:
Closeable, AutoCloseable

public class ThaiTokenizer extends SegmentingTokenizerBase
Tokenizer that uses BreakIterator to tokenize Thai text.

Supports an optional user dictionary (CharArraySet) for custom or domain-specific words. When a user dictionary word matches, it takes precedence over default segmentation boundaries.

WARNING: this tokenizer may not be supported by all JREs. It is known to work with Sun/Oracle and Harmony JREs. If your application needs to be fully portable, consider using ICUTokenizer instead, which uses an ICU Thai BreakIterator that will always be available.

  • Field Details

    • DBBI_AVAILABLE

      public static final boolean DBBI_AVAILABLE
      True if the JRE supports a working dictionary-based breakiterator for Thai. If this is false, this tokenizer will not work at all!
    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      Default buffer size in characters for Thai sentence segmentation
      See Also:
  • Constructor Details

    • ThaiTokenizer

      public ThaiTokenizer()
      Creates a new ThaiTokenizer
    • ThaiTokenizer

      public ThaiTokenizer(CharArraySet userDictionary)
      Creates a new ThaiTokenizer with a user dictionary.
      Parameters:
      userDictionary - custom dictionary of words, or null for default dictionary only
    • ThaiTokenizer

      public ThaiTokenizer(int bufferSize)
      Creates a new ThaiTokenizer with a custom buffer size.
      Parameters:
      bufferSize - internal buffer size in characters
    • ThaiTokenizer

      public ThaiTokenizer(CharArraySet userDictionary, int bufferSize)
      Creates a new ThaiTokenizer with a user dictionary and custom buffer size.
      Parameters:
      userDictionary - custom dictionary of words, or null for default dictionary only
      bufferSize - internal buffer size in characters
    • ThaiTokenizer

      public ThaiTokenizer(AttributeFactory factory)
      Creates a new ThaiTokenizer, supplying the AttributeFactory
    • ThaiTokenizer

      public ThaiTokenizer(AttributeFactory factory, CharArraySet userDictionary)
      Creates a new ThaiTokenizer, supplying the AttributeFactory and user dictionary.
      Parameters:
      factory - AttributeFactory to use
      userDictionary - custom dictionary of words, or null for default dictionary only
    • ThaiTokenizer

      public ThaiTokenizer(AttributeFactory factory, CharArraySet userDictionary, int bufferSize)
      Creates a new ThaiTokenizer, supplying the AttributeFactory, user dictionary, and buffer size.
      Parameters:
      factory - AttributeFactory to use
      userDictionary - custom dictionary of words, or null for default dictionary only
      bufferSize - internal buffer size in characters
  • Method Details