Package opennlp.tools.chunker
Class ChunkerME
- java.lang.Object
-
- opennlp.tools.chunker.ChunkerME
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BEAM_SIZE
-
Constructor Summary
Constructors Constructor Description ChunkerME(ChunkerModel model)
Initializes the current instance with the specified model.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
chunk(java.lang.String[] toks, java.lang.String[] tags)
Generates chunk tags for the given sequence returning the result in an array.Span[]
chunkAsSpans(java.lang.String[] toks, java.lang.String[] tags)
Generates tagged chunk spans for the given sequence returning the result in a span array.double[]
probs()
Returns an array with the probabilities of the last decoded sequence.void
probs(double[] probs)
Populates the specified array with the probabilities of the last decoded sequence.Sequence[]
topKSequences(java.lang.String[] sentence, java.lang.String[] tags)
Returns the top k chunk sequences for the specified sentence with the specified pos-tagsSequence[]
topKSequences(java.lang.String[] sentence, java.lang.String[] tags, double minSequenceScore)
Returns the top k chunk sequences for the specified sentence with the specified pos-tagsstatic ChunkerModel
train(java.lang.String lang, ObjectStream<ChunkSample> in, TrainingParameters mlParams, ChunkerFactory factory)
-
-
-
Field Detail
-
DEFAULT_BEAM_SIZE
public static final int DEFAULT_BEAM_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ChunkerME
public ChunkerME(ChunkerModel model)
Initializes the current instance with the specified model. The default beam size is used.- Parameters:
model
-
-
-
Method Detail
-
chunk
public java.lang.String[] chunk(java.lang.String[] toks, java.lang.String[] tags)
Description copied from interface:Chunker
Generates chunk tags for the given sequence returning the result in an array.
-
chunkAsSpans
public Span[] chunkAsSpans(java.lang.String[] toks, java.lang.String[] tags)
Description copied from interface:Chunker
Generates tagged chunk spans for the given sequence returning the result in a span array.- 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
public Sequence[] topKSequences(java.lang.String[] sentence, java.lang.String[] tags)
Description copied from interface:Chunker
Returns the top k chunk sequences 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
public Sequence[] topKSequences(java.lang.String[] sentence, java.lang.String[] tags, double minSequenceScore)
Description copied from interface:Chunker
Returns the top k chunk sequences 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.
-
probs
public void probs(double[] probs)
Populates the specified array with the probabilities of the last decoded sequence. The sequence was determined based on the previous call tochunk
. The specified array should be at least as large as the numbe of tokens in the previous call tochunk
.- Parameters:
probs
- An array used to hold the probabilities of the last decoded sequence.
-
probs
public double[] probs()
Returns an array with the probabilities of the last decoded sequence. The sequence was determined based on the previous call tochunk
.- Returns:
- An array with the same number of probabilities as tokens were sent to
chunk
when it was last called.
-
train
public static ChunkerModel train(java.lang.String lang, ObjectStream<ChunkSample> in, TrainingParameters mlParams, ChunkerFactory factory) throws java.io.IOException
- Throws:
java.io.IOException
-
-