Package opennlp.tools.postag
Class ThreadSafePOSTaggerME
java.lang.Object
opennlp.tools.postag.ThreadSafePOSTaggerME
- All Implemented Interfaces:
AutoCloseable,POSTagger
A thread-safe version of the POSTaggerME. Using it is completely transparent. You can use it in
a single-threaded context as well, it only incurs a minimal overhead.
Note, however, that this implementation uses a ThreadLocal. Although the implementation is
lightweight because the model is not duplicated, if you have many long-running threads,
you may run into memory problems.
Be careful when using this in a Jakarta EE application, for example.
The user is responsible for clearing theThreadLocal.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()String[]Assigns the sentence of tokens pos tags.String[]Assigns the sentence of tokens pos tags.Sequence[]topKSequences(String[] sentence) Assigns the sentence the top-ksequences.Sequence[]topKSequences(String[] sentence, Object[] additionaContext) Assigns the sentence the top-ksequences.
-
Constructor Details
-
ThreadSafePOSTaggerME
-
-
Method Details
-
tag
Description copied from interface:POSTaggerAssigns the sentence of tokens pos tags. -
tag
Description copied from interface:POSTaggerAssigns the sentence of tokens pos tags. -
topKSequences
Description copied from interface:POSTaggerAssigns the sentence the top-ksequences.- Specified by:
topKSequencesin interfacePOSTagger- Parameters:
sentence- The sentence of tokens to be tagged.- Returns:
- An array of
sequencesfor each token provided insentence.
-
topKSequences
Description copied from interface:POSTaggerAssigns the sentence the top-ksequences.- Specified by:
topKSequencesin interfacePOSTagger- Parameters:
sentence- The sentence of tokens to be tagged.additionaContext- The context to provide additional information with.- Returns:
- An array of
sequencesfor each token provided insentence.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-