Class BeamSearch

java.lang.Object
opennlp.tools.ml.BeamSearch
All Implemented Interfaces:
opennlp.tools.ml.model.SequenceClassificationModel

public class BeamSearch extends Object implements opennlp.tools.ml.model.SequenceClassificationModel
Performs k-best search over a sequence.

This is based on the description in Ratnaparkhi (1998), PhD diss, Univ. of Pennsylvania.

See Also:
  • Sequence
  • SequenceValidator
  • BeamSearchContextGenerator
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model)
    Initializes a BeamSearch instance.
    BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model, int cacheSize)
    Initializes a BeamSearch instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> opennlp.tools.util.Sequence
    bestSequence(T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator)
    Computes the best sequence of outcomes based on the MaxentModel.
    <T> opennlp.tools.util.Sequence[]
    bestSequences(int numSequences, T[] sequence, Object[] additionalContext, double minSequenceScore, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator)
    Computes the best sequence of outcomes based on the MaxentModel.
    <T> opennlp.tools.util.Sequence[]
    bestSequences(int numSequences, T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator)
    Computes the best sequence of outcomes based on the MaxentModel.
     

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • BeamSearch

      public BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model)
      Initializes a BeamSearch instance.
      Parameters:
      size - The size of the beam (k).
      model - The MaxentModel for assigning probabilities to the sequence outcomes.
    • BeamSearch

      public BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model, int cacheSize)
      Initializes a BeamSearch instance.
      Parameters:
      size - The size of the beam (k).
      model - The MaxentModel for assigning probabilities to the sequence outcomes.
      cacheSize - The capacity of the Cache to use.
  • Method Details

    • bestSequences

      public <T> opennlp.tools.util.Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, double minSequenceScore, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator)
      Computes the best sequence of outcomes based on the MaxentModel.
      Specified by:
      bestSequences in interface opennlp.tools.ml.model.SequenceClassificationModel
      Parameters:
      numSequences - The number of sequences.
      sequence - The input T sequence.
      additionalContext - An Object of additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.
      minSequenceScore - The minimum sequence score to use.
      cg - The context generator to use.
      validator - The SequenceValidator to validate sequences.
      Returns:
      The top ranked Sequence of outcomes or null if no sequence could be found.
    • bestSequences

      public <T> opennlp.tools.util.Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator)
      Computes the best sequence of outcomes based on the MaxentModel.
      Specified by:
      bestSequences in interface opennlp.tools.ml.model.SequenceClassificationModel
      Parameters:
      numSequences - The number of sequences.
      sequence - The input T sequence.
      additionalContext - An Object of additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.
      cg - The context generator to use.
      validator - The SequenceValidator to validate sequences.
      Returns:
      The top ranked Sequence of outcomes or null if no sequence could be found.
    • bestSequence

      public <T> opennlp.tools.util.Sequence bestSequence(T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator)
      Computes the best sequence of outcomes based on the MaxentModel.
      Specified by:
      bestSequence in interface opennlp.tools.ml.model.SequenceClassificationModel
      Parameters:
      sequence - The input T sequence.
      additionalContext - An Object of additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.
      cg - The context generator to use.
      validator - The SequenceValidator to validate sequences.
      Returns:
      The top ranked Sequence of outcomes or null if no sequence could be found.
    • getOutcomes

      public String[] getOutcomes()
      Specified by:
      getOutcomes in interface opennlp.tools.ml.model.SequenceClassificationModel