opennlp.tools.langdetect

## Class LanguageDetectorEvaluator

- java.lang.Object
- - opennlp.tools.util.eval.Evaluator<LanguageSample>
  - - opennlp.tools.langdetect.LanguageDetectorEvaluator

-     public class LanguageDetectorEvaluator
      extends Evaluator<LanguageSample>

  The `LanguageDetectorEvaluator` measures the performance of the given `LanguageDetector` with the provided reference `LanguageSample`s.
  See Also:
    `LanguageDetector`, `LanguageSample`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LanguageDetectorEvaluator(LanguageDetector langDetect, LanguageDetectorEvaluationMonitor... listeners)` Initializes the current instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getAccuracy()` Retrieves the accuracy of provided `DocumentCategorizer`.
    `long` | `getDocumentCount()`
    `LanguageSample` | `processSample(LanguageSample sample)` Evaluates the given reference `LanguageSample` object.
    `String` | `toString()` Represents this objects as human readable `String`.

    - ### Methods inherited from class opennlp.tools.util.eval.Evaluator

      `evaluate, evaluateSample`

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

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

- - ### Constructor Detail

    - #### LanguageDetectorEvaluator

          public LanguageDetectorEvaluator(LanguageDetector langDetect,
                                           LanguageDetectorEvaluationMonitor... listeners)

      Initializes the current instance.
      Parameters:
        `langDetect` - the language detector instance

  - ### Method Detail

    - #### processSample

          public LanguageSample processSample(LanguageSample sample)

      Evaluates the given reference `LanguageSample` object. This is done by categorizing the document from the provided `LanguageSample`. The detected language is then used to calculate and update the score.
      Parameters:
        `sample` - the reference `LanguageSample`.
      Returns:
        the predicted sample

    - #### getAccuracy

          public double getAccuracy()

      Retrieves the accuracy of provided `DocumentCategorizer`. accuracy = correctly categorized documents / total documents
      Returns:
        the accuracy

    - #### getDocumentCount

          public long getDocumentCount()

    - #### toString

          public String toString()

      Represents this objects as human readable `String`.
      Overrides:
        `toString` in class `Object`

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