Class MorfologikTagDictionary
java.lang.Object
opennlp.morfologik.tagdict.MorfologikTagDictionary
- All Implemented Interfaces:
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ThreadLocal<morfologik.stemming.IStemmer> private final boolean -
Constructor Summary
ConstructorsConstructorDescriptionMorfologikTagDictionary(morfologik.stemming.Dictionary dict) Initializes a case sensitiveMorfologikTagDictionaryMorfologikTagDictionary(morfologik.stemming.Dictionary dict, boolean caseSensitive) Initializes aMorfologikTagDictionary -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves theDictionaryLookupof the current thread to prevent classloader leaks in container environments.String[]Retrieves a list of valid tags for the specifiedword.booleanWhether the dictionary is case-sensitive or not.
-
Field Details
-
dictLookup
-
isCaseSensitive
private final boolean isCaseSensitive
-
-
Constructor Details
-
MorfologikTagDictionary
Initializes a case sensitiveMorfologikTagDictionary- Parameters:
dict- A Morfologik FSADictionary.- 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 Initializes aMorfologikTagDictionary- Parameters:
dict- A Morfologik FSADictionary.caseSensitive- Iftrueit performs case-sensitive lookup- Throws:
IllegalArgumentException- Thrown if FSA's root node cannot be acquired (dictionary is empty).
-
-
Method Details
-
getTags
Description copied from interface:TagDictionaryRetrieves a list of valid tags for the specifiedword.- Specified by:
getTagsin interfaceTagDictionary- Parameters:
word- The word.- Returns:
- An array of valid tags for the specified
wordornullif no information is available for that word.
-
isCaseSensitive
public boolean isCaseSensitive()Description copied from interface:TagDictionaryWhether the dictionary is case-sensitive or not.- Specified by:
isCaseSensitivein interfaceTagDictionary- Returns:
trueif the dictionary is case-sensitive, elsefalse.
-
clearThreadLocalState
public void clearThreadLocalState()Removes theDictionaryLookupof 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.
-