Class DependencyEvaluator

java.lang.Object
opennlp.tools.util.eval.Evaluator<DependencySample>
opennlp.tools.depparse.DependencyEvaluator

public class DependencyEvaluator extends Evaluator<DependencySample>
Measures the quality of a DependencyParser against gold samples with the two standard scores: the unlabeled attachment score (UAS, the fraction of tokens with the correct head) and the labeled attachment score (LAS, the fraction of tokens with the correct head and relation label).

Both scores are also kept over the tokens that are not punctuation, because treebank evaluations customarily leave punctuation out of the attachment scores. A token counts as punctuation when its gold part-of-speech tag satisfies the predicate given at construction; by default that is the universal tag UNIVERSAL_PUNCTUATION_TAG.

Since:
3.0.0
  • Field Details

    • UNIVERSAL_PUNCTUATION_TAG

      public static final String UNIVERSAL_PUNCTUATION_TAG
      The universal part-of-speech tag of punctuation, which the default constructor excludes from the punctuation-free scores.
      See Also:
    • parser

      private final DependencyParser parser
    • punctuationTag

      private final Predicate<String> punctuationTag
    • scores

      private final AttachmentScores scores
  • Constructor Details

  • Method Details

    • processSample

      protected DependencySample processSample(DependencySample reference)
      Evaluates the given reference Evaluator sample object.

      The implementation has to update the score after every invocation.

      The returned sample carries the predicted tree over the reference tokens, and every token of the reference contributes to both scores. Listeners are told whether the predicted tree equals the gold tree.

      Specified by:
      processSample in class Evaluator<DependencySample>
      Parameters:
      reference - A reference sample.
      Returns:
      The predicted sample.
    • getUas

      public double getUas()
      Returns:
      The unlabeled attachment score over all evaluated tokens.
    • getLas

      public double getLas()
      Returns:
      The labeled attachment score over all evaluated tokens.
    • getWordCount

      public long getWordCount()
      Returns:
      The number of tokens scored so far.
    • getUasExcludingPunctuation

      public double getUasExcludingPunctuation()
      Returns:
      The unlabeled attachment score over the evaluated tokens that are not punctuation.
    • getLasExcludingPunctuation

      public double getLasExcludingPunctuation()
      Returns:
      The labeled attachment score over the evaluated tokens that are not punctuation.
    • getWordCountExcludingPunctuation

      public long getWordCountExcludingPunctuation()
      Returns:
      The number of tokens scored so far that are not punctuation.
    • scores

      Returns:
      The accumulated scores, for merging into a cross validation total.