Package opennlp.tools.depparse
Class ArcStandardBeam
java.lang.Object
opennlp.tools.depparse.ArcStandardBeam
One step of arc-standard beam search over a
FeedforwardNetwork, shared by
beam decoding and beam refinement: every node of the beam is expanded by each
applicable transition scored by summed log-probability, and the best expansions
are advanced.- Since:
- 3.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classOne path of the beam. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intThe transition index of the start node, which took no transition. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrevents construction of this utility class. -
Method Summary
Modifier and TypeMethodDescription(package private) static List<ArcStandardBeam.Node> advance(List<ArcStandardBeam.Node> expansions, int beamSize, Transition[] transitions) Keeps the best expansions and advances their states.(package private) static List<ArcStandardBeam.Node> expand(List<ArcStandardBeam.Node> beam, FeedforwardContext context, FeedforwardNetwork network, ContributionCache cache, Transition[] transitions, int goldTransition, double[] hidden, double[] scores) Expands every node of the beam by its applicable transitions.
-
Field Details
-
NO_TRANSITION
static final int NO_TRANSITIONThe transition index of the start node, which took no transition.- See Also:
-
-
Constructor Details
-
ArcStandardBeam
private ArcStandardBeam()Prevents construction of this utility class.
-
-
Method Details
-
expand
static List<ArcStandardBeam.Node> expand(List<ArcStandardBeam.Node> beam, FeedforwardContext context, FeedforwardNetwork network, ContributionCache cache, Transition[] transitions, int goldTransition, double[] hidden, double[] scores) Expands every node of the beam by its applicable transitions. Terminal nodes pass through unchanged.- Parameters:
beam- The nodes to expand, each with its state set.context- The sentence features.network- The network scoring the configurations.cache- The contribution cache to score with, ornull.transitions- The decoded transition inventory.goldTransition- The transition index that continues the gold derivation, orNO_TRANSITIONwhen the gold path is not tracked.hidden- Scratch space for the hidden layer of the network; overwritten.scores- Scratch space for the transition scores of the network; overwritten.- Returns:
- The expansions, sorted by descending score, with their states unset.
Never
null. - Throws:
IllegalStateException- Thrown if the network produces a non-finite score.
-
advance
static List<ArcStandardBeam.Node> advance(List<ArcStandardBeam.Node> expansions, int beamSize, Transition[] transitions) Keeps the best expansions and advances their states.- Parameters:
expansions- The expansions in descending score order.beamSize- The number of nodes to keep.transitions- The decoded transition inventory.- Returns:
- The survivors, each with its state set. Never
null.
-