Class DependencySample

java.lang.Object
opennlp.tools.depparse.DependencySample
All Implemented Interfaces:
Serializable, Sample

@ThreadSafe public final class DependencySample extends Object implements Sample
One dependency-annotated sentence: tokens, their part-of-speech tags, and the gold DependencyTree over them. Used for training and evaluating a DependencyParser.

Instances are immutable and safe to share between threads.

Since:
3.0.0
See Also:
  • Constructor Details

    • DependencySample

      public DependencySample(String[] tokens, String[] tags, DependencyTree tree)
      Initializes a DependencySample.
      Parameters:
      tokens - The input tokens. Must not be null or empty and must not contain null entries.
      tags - The part-of-speech tags aligned with tokens. Must not be null, must have the same length as tokens, and must not contain null entries.
      tree - The dependency tree over the tokens. Must not be null and its DependencyTree.size() must equal the number of tokens.
      Throws:
      IllegalArgumentException - Thrown if any parameter is null, tokens is empty, tokens or tags contains a null entry, or the lengths of tokens, tags and tree disagree.
  • Method Details

    • getTokens

      public String[] getTokens()
      Returns:
      The tokens of the sentence. Never null.
    • getTags

      public String[] getTags()
      Returns:
      The part-of-speech tags aligned with the tokens. Never null.
    • getTree

      public DependencyTree getTree()
      Returns:
      The dependency tree over the tokens. Never null.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object