Class MorfologikTagDictionary

java.lang.Object
opennlp.morfologik.tagdict.MorfologikTagDictionary
All Implemented Interfaces:
opennlp.tools.postag.TagDictionary

public class MorfologikTagDictionary extends Object implements opennlp.tools.postag.TagDictionary
A TagDictionary implementation based on Morfologik binary dictionaries.

This implementation is thread-safe: the immutable Dictionary is shared and each thread looks words up through its own DictionaryLookup, held in a ThreadLocal, as DictionaryLookup instances are stateful and must not be used concurrently. Call clearThreadLocalState() to release the lookup of the current thread.

  • Constructor Details

    • MorfologikTagDictionary

      public MorfologikTagDictionary(morfologik.stemming.Dictionary dict) throws IllegalArgumentException
      Initializes a case sensitive MorfologikTagDictionary
      Parameters:
      dict - A Morfologik FSA Dictionary.
      Throws:
      IllegalArgumentException - Thrown if FSA's root node cannot be acquired (dictionary is empty).
    • MorfologikTagDictionary

      public MorfologikTagDictionary(morfologik.stemming.Dictionary dict, boolean caseSensitive) throws IllegalArgumentException
      Parameters:
      dict - A Morfologik FSA Dictionary.
      caseSensitive - If true it performs case-sensitive lookup
      Throws:
      IllegalArgumentException - Thrown if FSA's root node cannot be acquired (dictionary is empty).
  • Method Details

    • getTags

      public String[] getTags(String word)
      Specified by:
      getTags in interface opennlp.tools.postag.TagDictionary
    • isCaseSensitive

      public boolean isCaseSensitive()
      Specified by:
      isCaseSensitive in interface opennlp.tools.postag.TagDictionary
    • clearThreadLocalState

      public void clearThreadLocalState()
      Removes the DictionaryLookup of the current thread to prevent classloader leaks in container environments. Call when the thread is returned to a pool or the dictionary is no longer needed; a later lookup on the same thread creates a new one.