Class ArcStandardOracle

java.lang.Object
opennlp.tools.depparse.ArcStandardOracle

final class ArcStandardOracle extends Object
Converts an annotated dependency tree into the sequence of parser transitions needed to reconstruct it. These transitions provide the training targets for the arc-standard dependency parser.

The annotated tree, also called the gold tree, supplies the correct head and dependency relation for each token. At each step, the oracle uses this tree and the current ArcStandardState to choose a transition:

  • SHIFT: move the next token from the buffer onto the stack.
  • LEFT_ARC(label): attach the token immediately below the top of the stack to the top token, then remove the dependent.
  • RIGHT_ARC(label): attach the top token to the token immediately below it, then remove the dependent.

A token must have all its dependents attached before it is removed from the stack. Only projective trees can be reconstructed with these transitions. In a projective tree, dependency arcs do not cross when drawn above the token sequence. Non-projective trees are rejected.

Since:
3.0.0
  • Constructor Details

    • ArcStandardOracle

      private ArcStandardOracle()
      Prevents construction of this utility class.
  • Method Details

    • transitions

      static List<Transition> transitions(DependencyTree gold)
      Derives the gold transition sequence for a tree.
      Parameters:
      gold - The gold dependency tree. Must not be null and must be projective.
      Returns:
      The transitions that rebuild gold from the start configuration, in order. Never null.
      Throws:
      IllegalArgumentException - Thrown if gold is null or not projective.
    • nextTransition

      private static Transition nextTransition(DependencyTree gold, int[] goldDependents, ArcStandardState state)
      Picks the gold transition for the current configuration.
      Parameters:
      gold - The gold tree being derived.
      goldDependents - The gold dependent count per token, indexed by head.
      state - The current configuration.
      Returns:
      The next gold transition, or null when the configuration is stuck, which only happens for non-projective input.
    • isProjective

      static boolean isProjective(DependencyTree gold)
      Tests whether a gold tree is projective: no pair of arcs crosses when the arcs are placed above the token sequence. The projective trees are the ones with an arc-standard derivation, so callers apply this test before requesting transitions(opennlp.tools.depparse.DependencyTree).
      Parameters:
      gold - The gold tree. Must not be null.
      Returns:
      true if no pair of arcs crosses.
      Throws:
      IllegalArgumentException - Thrown if gold is null.