Class ChunkerME
java.lang.Object
opennlp.tools.chunker.ChunkerME
- All Implemented Interfaces:
opennlp.tools.chunker.Chunker, opennlp.tools.ml.Probabilistic
public class ChunkerME
extends Object
implements opennlp.tools.chunker.Chunker, opennlp.tools.ml.Probabilistic
The class represents a maximum-entropy-based
Chunker. A chunker can be used to
find flat structures based on sequence inputs such as noun phrases or named entities.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitializes aChunkerby downloading a default model.ChunkerME(ChunkerModel model) Initializes aChunkerwith the specifiedChunkerModel. -
Method Summary
Modifier and TypeMethodDescriptionString[]opennlp.tools.util.Span[]chunkAsSpans(String[] toks, String[] tags) double[]probs()The sequence was determined based on the previous call tochunk(String[], String[]).voidprobs(double[] probs) Populates the specified array with the probabilities of the last decoded sequence.opennlp.tools.util.Sequence[]topKSequences(String[] sentence, String[] tags) opennlp.tools.util.Sequence[]topKSequences(String[] sentence, String[] tags, double minSequenceScore) static ChunkerModeltrain(String lang, opennlp.tools.util.ObjectStream<opennlp.tools.chunker.ChunkSample> in, opennlp.tools.util.TrainingParameters mlParams, ChunkerFactory factory) Starts a training of aChunkerModelwith the given parameters.
-
Field Details
-
DEFAULT_BEAM_SIZE
public static final int DEFAULT_BEAM_SIZE- See Also:
-
-
Constructor Details
-
ChunkerME
Initializes aChunkerby downloading a default model.- Parameters:
language- The language of the model.- Throws:
IOException- Thrown if the model cannot be downloaded or saved.
-
ChunkerME
- Parameters:
model- A validmodelinstance.
-
-
Method Details
-
chunk
-
chunkAsSpans
-
topKSequences
-
topKSequences
-
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 number 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()The sequence was determined based on the previous call tochunk(String[], String[]).- Specified by:
probsin interfaceopennlp.tools.ml.Probabilistic- Returns:
- An array with the same number of probabilities as tokens when
chunk(String[], String[])was last called.
-
train
public static ChunkerModel train(String lang, opennlp.tools.util.ObjectStream<opennlp.tools.chunker.ChunkSample> in, opennlp.tools.util.TrainingParameters mlParams, ChunkerFactory factory) throws IOException Starts a training of aChunkerModelwith the given parameters.- Parameters:
lang- The ISO conform language code.in- TheObjectStreamofChunkSampleused as input for training.mlParams- TheTrainingParametersfor the context of the training.factory- TheChunkerFactoryfor creating related objects defined viamlParams.- Returns:
- A valid, trained
ChunkerModelinstance. - Throws:
IOException- Thrown if IO errors occurred.IllegalArgumentException- Thrown if the specifiedTrainerFactory.TrainerTypeis not supported.
-