Package 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
  Description
  `LanguageDetectorEvaluator(LanguageDetector langDetect, LanguageDetectorEvaluationMonitor... listeners)`
  Initializes an instance to evaluate a `LanguageDetector`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `double`
  `getAccuracy()`
  `long`
  `getDocumentCount()`
  `LanguageSample`
  `processSample(LanguageSample sample)`
  Evaluates the given reference `LanguageSample` object.
  `String`
  `toString()`
  Represents this object 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 Details

  - ### LanguageDetectorEvaluator

    public LanguageDetectorEvaluator(LanguageDetector langDetect, LanguageDetectorEvaluationMonitor... listeners)
    Initializes an instance to evaluate a `LanguageDetector`.
    Parameters:
      `langDetect` - the `LanguageDetector` to evaluate.
      `listeners` - the `evaluation listeners`.

- ## Method Details

  - ### processSample

    public LanguageSample processSample(LanguageSample sample)
    Evaluates the given reference `LanguageSample` object. This is achieved by categorizing the document of the provided `LanguageSample`. The detected language is then used to calculate and update the score.
    Parameters:
      `sample` - the reference `LanguageSample`.
    Returns:
      The processed `LanguageSample`.

  - ### getAccuracy

    public double getAccuracy()
    Returns:
      Retrieves the accuracy of provided `DocumentCategorizer`. Here: `accuracy = correctly categorized documents / total documents`.

  - ### getDocumentCount

    public long getDocumentCount()

  - ### toString

    public String toString()
    Represents this object as human-readable `String`.
    Overrides:
      `toString` in class `Object`