opennlp.tools.postag

## Class POSTaggerCrossValidator

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

-     public class POSTaggerCrossValidator
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, File tagDictionary, byte[] featureGeneratorBytes, Map<String,Object> resources, Integer tagdicCutoff, String factoryClass, POSTaggerEvaluationMonitor... listeners)` Creates a `POSTaggerCrossValidator` that builds a ngram dictionary dynamically.
    `POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTaggerEvaluationMonitor... listeners)` Creates a `POSTaggerCrossValidator` using the given `POSTaggerFactory`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `evaluate(ObjectStream<POSSample> samples, int nFolds)` Starts the evaluation.
    `double` | `getWordAccuracy()` Retrieves the accuracy for all iterations.
    `long` | `getWordCount()` Retrieves the number of words which where validated over all iterations.

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

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

- - ### Constructor Detail

    - #### POSTaggerCrossValidator

          public POSTaggerCrossValidator(String languageCode,
                                         TrainingParameters trainParam,
                                         File tagDictionary,
                                         byte[] featureGeneratorBytes,
                                         Map<String,Object> resources,
                                         Integer tagdicCutoff,
                                         String factoryClass,
                                         POSTaggerEvaluationMonitor... listeners)

      Creates a `POSTaggerCrossValidator` that builds a ngram dictionary dynamically. It instantiates a sub-class of `POSTaggerFactory` using the tag and the ngram dictionaries.

    - #### POSTaggerCrossValidator

          public POSTaggerCrossValidator(String languageCode,
                                         TrainingParameters trainParam,
                                         POSTaggerFactory factory,
                                         POSTaggerEvaluationMonitor... listeners)

      Creates a `POSTaggerCrossValidator` using the given `POSTaggerFactory`.

  - ### Method Detail

    - #### evaluate

          public void evaluate(ObjectStream<POSSample> samples,
                               int nFolds)
                        throws IOException

      Starts the evaluation.
      Parameters:
        `samples` - the data to train and test
        `nFolds` - number of folds
      Throws:
        `IOException`

    - #### getWordAccuracy

          public double getWordAccuracy()

      Retrieves the accuracy for all iterations.
      Returns:
        the word accuracy

    - #### getWordCount

          public long getWordCount()

      Retrieves the number of words which where validated over all iterations. The result is the amount of folds multiplied by the total number of words.
      Returns:
        the word count

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