Package opennlp.tools.depparse
Class ArcStandardOracle
java.lang.Object
opennlp.tools.depparse.ArcStandardOracle
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 Summary
ConstructorsModifierConstructorDescriptionprivatePrevents construction of this utility class. -
Method Summary
Modifier and TypeMethodDescription(package private) static booleanisProjective(DependencyTree gold) Tests whether a gold tree is projective: no pair of arcs crosses when the arcs are placed above the token sequence.private static TransitionnextTransition(DependencyTree gold, int[] goldDependents, ArcStandardState state) Picks the gold transition for the current configuration.(package private) static List<Transition> transitions(DependencyTree gold) Derives the gold transition sequence for a tree.
-
Constructor Details
-
ArcStandardOracle
private ArcStandardOracle()Prevents construction of this utility class.
-
-
Method Details
-
transitions
Derives the gold transition sequence for a tree.- Parameters:
gold- The gold dependency tree. Must not benulland must be projective.- Returns:
- The transitions that rebuild
goldfrom the start configuration, in order. Nevernull. - Throws:
IllegalArgumentException- Thrown ifgoldisnullor 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
nullwhen the configuration is stuck, which only happens for non-projective input.
-
isProjective
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 requestingtransitions(opennlp.tools.depparse.DependencyTree).- Parameters:
gold- The gold tree. Must not benull.- Returns:
trueif no pair of arcs crosses.- Throws:
IllegalArgumentException- Thrown ifgoldisnull.
-