opennlp.tools.postag

## Class POSTaggerME

- java.lang.Object
- - opennlp.tools.postag.POSTaggerME

- All Implemented Interfaces:
    POSTagger

      public class POSTaggerME
      extends Object
      implements 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
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_BEAM_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `POSTaggerME(POSModel model)` Initializes the current instance with the provided model.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Dictionary` | `buildNGramDictionary(ObjectStream<POSSample> samples, int cutoff)`
    `String[]` | `getAllPosTags()` 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 void` | `populatePOSDictionary(ObjectStream<POSSample> samples, MutableTagDictionary dict, int cutoff)`
    `double[]` | `probs()` Returns an array with the probabilities for each tag of the last tagged sentence.
    `void` | `probs(double[] probs)` Populates the specified array with the probabilities for each tag of the last tagged sentence.
    `String[][]` | `tag(int numTaggings, String[] sentence)` Returns at most the specified number of taggings for the specified sentence.
    `String[]` | `tag(String[] sentence)` Assigns the sentence of tokens pos tags.
    `String[]` | `tag(String[] sentence, Object[] additionaContext)`
    `Sequence[]` | `topKSequences(String[] sentence)`
    `Sequence[]` | `topKSequences(String[] sentence, Object[] additionaContext)`
    `static POSModel` | `train(String languageCode, ObjectStream<POSSample> samples, TrainingParameters trainParams, POSTaggerFactory posFactory)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_BEAM_SIZE

          public static final int DEFAULT_BEAM_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### POSTaggerME

          public POSTaggerME(POSModel model)

      Initializes the current instance with the provided model.
      Parameters:
        `model` -

  - ### Method Detail

    - #### getAllPosTags

          public String[] getAllPosTags()

      Retrieves an array of all possible part-of-speech tags from the tagger.
      Returns:
        String[]

    - #### tag

          public String[] tag(String[] sentence)

      Description copied from interface: `POSTagger`
      Assigns the sentence of tokens pos tags.
      Specified by:
        `tag` in interface `POSTagger`
      Parameters:
        `sentence` - The sentece of tokens to be tagged.
      Returns:
        an array of pos tags for each token provided in sentence.

    - #### tag

          public String[] tag(String[] sentence,
                              Object[] additionaContext)

      Specified by:
        `tag` in interface `POSTagger`

    - #### tag

          public String[][] tag(int numTaggings,
                                String[] sentence)

      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

          public Sequence[] topKSequences(String[] sentence)

      Specified by:
        `topKSequences` in interface `POSTagger`

    - #### topKSequences

          public Sequence[] topKSequences(String[] sentence,
                                          Object[] additionaContext)

      Specified by:
        `topKSequences` in interface `POSTagger`

    - #### 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

          public String[] getOrderedTags(List<String> words,
                                         List<String> tags,
                                         int index)

    - #### getOrderedTags

          public String[] getOrderedTags(List<String> words,
                                         List<String> tags,
                                         int index,
                                         double[] tprobs)

    - #### 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`

Copyright © 2026 The Apache Software Foundation. All rights reserved.