Class ArcStandardBeam

java.lang.Object
opennlp.tools.depparse.ArcStandardBeam

final class ArcStandardBeam extends Object
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
  • Field Details

    • NO_TRANSITION

      static final int NO_TRANSITION
      The 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, or null.
      transitions - The decoded transition inventory.
      goldTransition - The transition index that continues the gold derivation, or NO_TRANSITION when 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.