Package opennlp.tools.postag
Class POSTaggerME
java.lang.Object
opennlp.tools.postag.POSTaggerME
- All Implemented Interfaces:
POSTagger
A part-of-speech tagger that uses maximum entropy. Tries to predict whether
words are nouns, verbs, or any of 70 other POS tags depending on their
surrounding context.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPOSTaggerME(POSModel model) Initializes the current instance with the provided model. -
Method Summary
Modifier and TypeMethodDescriptionstatic DictionarybuildNGramDictionary(ObjectStream<POSSample> samples, int cutoff) String[]Retrieves an array of all possible part-of-speech tags from the tagger.String[]getOrderedTags(List<String> words, List<String> tags, int index) String[]getOrderedTags(List<String> words, List<String> tags, int index, double[] tprobs) static voidpopulatePOSDictionary(ObjectStream<POSSample> samples, MutableTagDictionary dict, int cutoff) double[]probs()Returns an array with the probabilities for each tag of the last tagged sentence.voidprobs(double[] probs) Populates the specified array with the probabilities for each tag of the last tagged sentence.String[][]Returns at most the specified number of taggings for the specified sentence.String[]Assigns the sentence of tokens pos tags.String[]Sequence[]topKSequences(String[] sentence) Sequence[]topKSequences(String[] sentence, Object[] additionaContext) static POSModeltrain(String languageCode, ObjectStream<POSSample> samples, TrainingParameters trainParams, POSTaggerFactory posFactory)
-
Field Details
-
DEFAULT_BEAM_SIZE
public static final int DEFAULT_BEAM_SIZE- See Also:
-
-
Constructor Details
-
POSTaggerME
Initializes the current instance with the provided model.- Parameters:
model-
-
-
Method Details
-
getAllPosTags
Retrieves an array of all possible part-of-speech tags from the tagger.- Returns:
- String[]
-
tag
Description copied from interface:POSTaggerAssigns the sentence of tokens pos tags. -
tag
-
tag
Returns at most the specified number of taggings for the specified sentence.- Parameters:
numTaggings- The number of tagging to be returned.sentence- An array of tokens which make up a sentence.- Returns:
- At most the specified number of taggings for the specified sentence.
-
topKSequences
- Specified by:
topKSequencesin interfacePOSTagger
-
topKSequences
- Specified by:
topKSequencesin interfacePOSTagger
-
probs
public void probs(double[] probs) Populates the specified array with the probabilities for each tag of the last tagged sentence.- Parameters:
probs- An array to put the probabilities into.
-
probs
public double[] probs()Returns an array with the probabilities for each tag of the last tagged sentence.- Returns:
- an array with the probabilities for each tag of the last tagged sentence.
-
getOrderedTags
-
getOrderedTags
-
train
public static POSModel train(String languageCode, ObjectStream<POSSample> samples, TrainingParameters trainParams, POSTaggerFactory posFactory) throws IOException - Throws:
IOException
-
buildNGramDictionary
public static Dictionary buildNGramDictionary(ObjectStream<POSSample> samples, int cutoff) throws IOException - Throws:
IOException
-
populatePOSDictionary
public static void populatePOSDictionary(ObjectStream<POSSample> samples, MutableTagDictionary dict, int cutoff) throws IOException - Throws:
IOException
-