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.- See Also:
-
Constructor Summary
ConstructorDescriptionThreadSafePOSTaggerME
(String language) Initializes aThreadSafePOSTaggerME
by downloading a default model for a givenlanguage
.ThreadSafePOSTaggerME
(String language, POSTagFormat format) Initializes aThreadSafePOSTaggerME
by downloading a default model for a givenlanguage
.ThreadSafePOSTaggerME
(POSModel model) Initializes aThreadSafePOSTaggerME
with the specifiedmodel
.ThreadSafePOSTaggerME
(POSModel model, POSTagFormat format) Initializes aThreadSafePOSTaggerME
with the specifiedmodel
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
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
Initializes aThreadSafePOSTaggerME
by downloading a default model for a givenlanguage
.- Parameters:
language
- An ISO conform language code.- Throws:
IOException
- Thrown if the model could not be downloaded or saved.
-
ThreadSafePOSTaggerME
Initializes aThreadSafePOSTaggerME
by downloading a default model for a givenlanguage
.- Parameters:
language
- An ISO conform language code.format
- A validPOSTagFormat
.- Throws:
IOException
- Thrown if the model could not be downloaded or saved.
-
ThreadSafePOSTaggerME
Initializes aThreadSafePOSTaggerME
with the specifiedmodel
.- Parameters:
model
- A validPOSModel
.
-
ThreadSafePOSTaggerME
Initializes aThreadSafePOSTaggerME
with the specifiedmodel
.- Parameters:
model
- A validPOSModel
.format
- A validPOSTagFormat
.
-
-
Method Details
-
tag
Description copied from interface:POSTagger
Assigns the sentence of tokens pos tags. -
tag
Description copied from interface:POSTagger
Assigns the sentence of tokens pos tags. -
topKSequences
Description copied from interface:POSTagger
Assigns the sentence the top-ksequences
.- Specified by:
topKSequences
in interfacePOSTagger
- Parameters:
sentence
- The sentence of tokens to be tagged.- Returns:
- An array of
sequences
for each token provided insentence
.
-
topKSequences
Description copied from interface:POSTagger
Assigns the sentence the top-ksequences
.- Specified by:
topKSequences
in interfacePOSTagger
- Parameters:
sentence
- The sentence of tokens to be tagged.additionaContext
- The context to provide additional information with.- Returns:
- An array of
sequences
for each token provided insentence
.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-