Package opennlp.tools.chunker
Class ThreadSafeChunkerME
java.lang.Object
opennlp.tools.chunker.ThreadSafeChunkerME
- All Implemented Interfaces:
AutoCloseable
,Chunker
A thread-safe version of the
ChunkerME
. 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
ConstructorsConstructorDescriptionThreadSafeChunkerME
(ChunkerModel model) Initializes aThreadSafeChunkerME
with the specifiedmodel
. -
Method Summary
Modifier and TypeMethodDescriptionString[]
Generates chunk tags for the given sequence returning the result in an array.Span[]
chunkAsSpans
(String[] toks, String[] tags) void
close()
Sequence[]
topKSequences
(String[] sentence, String[] tags) Computes the top k chunksequences
for the specified sentence with the specified pos-tags.Sequence[]
topKSequences
(String[] sentence, String[] tags, double minSequenceScore) Computes the top k chunksequences
for the specified sentence with the specified pos-tags.
-
Constructor Details
-
ThreadSafeChunkerME
Initializes aThreadSafeChunkerME
with the specifiedmodel
.- Parameters:
model
- A validChunkerModel
.
-
-
Method Details
-
chunk
Description copied from interface:Chunker
Generates chunk tags for the given sequence returning the result in an array. -
chunkAsSpans
Description copied from interface:Chunker
- Specified by:
chunkAsSpans
in interfaceChunker
- Parameters:
toks
- an array of the tokens or words of the sequence.tags
- an array of the pos tags of the sequence.- Returns:
- an array of
spans
with chunk tags for each chunk in the sequence.
-
topKSequences
Description copied from interface:Chunker
Computes the top k chunksequences
for the specified sentence with the specified pos-tags.- Specified by:
topKSequences
in interfaceChunker
- Parameters:
sentence
- The tokens of the sentence.tags
- The pos-tags for the specified sentence.- Returns:
- the top k chunk
sequences
for the specified sentence.
-
topKSequences
Description copied from interface:Chunker
Computes the top k chunksequences
for the specified sentence with the specified pos-tags.- Specified by:
topKSequences
in interfaceChunker
- Parameters:
sentence
- The tokens of the sentence.tags
- The pos-tags for the specified sentence.minSequenceScore
- A lower bound on the score of a returned sequence.- Returns:
- the top k chunk
sequences
for the specified sentence.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-