Package opennlp.tools.stemmer.snowball
Class SnowballStemmer
java.lang.Object
opennlp.tools.stemmer.snowball.SnowballStemmer
- All Implemented Interfaces:
opennlp.tools.stemmer.Stemmer
A
Stemmer backed by the generated Snowball engines.
The generated engines hold mutable per-call buffers, so this class routes each call to a
per-thread engine, the same pattern the thread-safe *ME components use. A single
SnowballStemmer instance is therefore safe to share across threads.
As with the *ME components, long-running environments such as application
containers should call clearThreadLocalState() when a pooled thread no longer uses
this stemmer; otherwise the thread retains its engine until the instance is unreachable,
which can pin the defining classloader on redeploys.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSnowballStemmer(SnowballStemmer.ALGORITHM algorithm) Creates a stemmer for the given algorithm withrepeat = 1.SnowballStemmer(SnowballStemmer.ALGORITHM algorithm, int repeat) Creates a stemmer for the given algorithm and repeat count. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves this thread's engine to prevent classloader leaks in container environments.stem(CharSequence word) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.stemmer.Stemmer
stemAll
-
Constructor Details
-
SnowballStemmer
Creates a stemmer for the given algorithm and repeat count.- Parameters:
algorithm- The Snowball algorithm. Must not benull.repeat- How many times to apply the stemmer per word; must be positive.- Throws:
IllegalArgumentException- Thrown ifalgorithmisnullorrepeatis not positive.
-
SnowballStemmer
Creates a stemmer for the given algorithm withrepeat = 1.- Parameters:
algorithm- The Snowball algorithm. Must not benull.- Throws:
IllegalArgumentException- Thrown ifalgorithmisnull.
-
-
Method Details
-
stem
- Specified by:
stemin interfaceopennlp.tools.stemmer.Stemmer
-
clearThreadLocalState
public void clearThreadLocalState()Removes this thread's engine to prevent classloader leaks in container environments. Call when the thread is returned to a pool or the stemmer is no longer needed, mirroringclearThreadLocalState()on the thread-safe*MEcomponents.
-