Class LemmatizerME
java.lang.Object
opennlp.tools.lemmatizer.LemmatizerME
- All Implemented Interfaces:
opennlp.tools.lemmatizer.Lemmatizer, opennlp.tools.ml.Probabilistic
public class LemmatizerME
extends Object
implements opennlp.tools.lemmatizer.Lemmatizer, opennlp.tools.ml.Probabilistic
A probabilistic
Lemmatizer implementation.
Tries to predict the induced permutation class for each word depending on its surrounding context.
Based on Grzegorz ChrupaĆa. 2008. Towards a Machine-Learning Architecture for Lexical Functional Grammar Parsing. PhD dissertation, Dublin City University
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]decodeLemmas(String[] toks, String[] preds) Decodes the lemma from the word and the induced lemma class.static String[]encodeLemmas(String[] toks, String[] lemmas) Encodes the word given its lemmas.String[]String[][]predictLemmas(int numLemmas, String[] toks, String[] tags) Predict all possible lemmas (using a default upper bound).String[]predictSES(String[] toks, String[] tags) Predict Short Edit Script (automatically induced lemma class).double[]probs()The sequence was determined based on the previous call tolemmatize(String[], String[]).voidprobs(double[] probs) Populates the specified array with the probabilities of the last decoded sequence.opennlp.tools.util.Sequence[]topKLemmaClasses(String[] sentence, String[] tags) opennlp.tools.util.Sequence[]topKLemmaClasses(String[] sentence, String[] tags, double minSequenceScore) opennlp.tools.util.Sequence[]topKSequences(String[] sentence, String[] tags) opennlp.tools.util.Sequence[]topKSequences(String[] sentence, String[] tags, double minSequenceScore) static LemmatizerModeltrain(String languageCode, opennlp.tools.util.ObjectStream<opennlp.tools.lemmatizer.LemmaSample> samples, opennlp.tools.util.TrainingParameters params, LemmatizerFactory factory) Starts a training of aLemmatizerModelwith the given parameters.
-
Field Details
-
LEMMA_NUMBER
public static final int LEMMA_NUMBER- See Also:
-
DEFAULT_BEAM_SIZE
public static final int DEFAULT_BEAM_SIZE- See Also:
-
-
Constructor Details
-
LemmatizerME
- Parameters:
model- TheLemmatizerModelto be used.
-
-
Method Details
-
lemmatize
-
lemmatize
-
predictSES
-
predictLemmas
Predict all possible lemmas (using a default upper bound).- Parameters:
numLemmas- The default number of lemmastoks- An array of tokens.tags- An array of postags.- Returns:
- A 2-dimensional array containing all possible lemmas for each token and postag pair.
-
decodeLemmas
-
encodeLemmas
-
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 tolemmatize(String[], String[]).The specified array should be at least as large as the number of tokens in the previous call to
lemmatize(String[], String[]).- 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 tolemmatize(String[], String[]).- Specified by:
probsin interfaceopennlp.tools.ml.Probabilistic- Returns:
- An array with the same number of probabilities as tokens were sent to
lemmatize(String[], String[])when it was last called.
-
train
public static LemmatizerModel train(String languageCode, opennlp.tools.util.ObjectStream<opennlp.tools.lemmatizer.LemmaSample> samples, opennlp.tools.util.TrainingParameters params, LemmatizerFactory factory) throws IOException Starts a training of aLemmatizerModelwith the given parameters.- Parameters:
languageCode- The ISO conform language code.samples- TheObjectStreamofLemmaSampleused as input for training.params- TheTrainingParametersfor the context of the training.factory- TheLemmatizerFactoryfor creating related objects defined viaparams.- Returns:
- A valid, trained
LemmatizerModelinstance. - Throws:
IOException- Thrown if IO errors occurred.
-
topKLemmaClasses
-
topKLemmaClasses
-