Package opennlp.tools.util
Class BeamSearch<T>
- java.lang.Object
-
- opennlp.tools.util.BeamSearch<T>
-
public class BeamSearch<T> extends java.lang.ObjectPerforms k-best search over sequence. This is based on the description in Ratnaparkhi (1998), PhD diss, Univ. of Pennsylvania.- See Also:
Sequence,SequenceValidator,BeamSearchContextGenerator
-
-
Constructor Summary
Constructors Constructor Description BeamSearch(int size, BeamSearchContextGenerator<T> cg, MaxentModel model)Creates new search object.BeamSearch(int size, BeamSearchContextGenerator<T> cg, MaxentModel model, int cacheSize)BeamSearch(int size, BeamSearchContextGenerator<T> cg, MaxentModel model, SequenceValidator<T> validator, int cacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SequencebestSequence(T[] sequence, java.lang.Object[] additionalContext)Returns the best sequence of outcomes based on model for this object.Sequence[]bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext)Sequence[]bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext, double minSequenceScore)Returns the best sequence of outcomes based on model for this object.
-
-
-
Constructor Detail
-
BeamSearch
public BeamSearch(int size, BeamSearchContextGenerator<T> cg, MaxentModel model)Creates new search object.- Parameters:
size- The size of the beam (k).cg- the context generator for the model.model- the model for assigning probabilities to the sequence outcomes.
-
BeamSearch
public BeamSearch(int size, BeamSearchContextGenerator<T> cg, MaxentModel model, int cacheSize)
-
BeamSearch
public BeamSearch(int size, BeamSearchContextGenerator<T> cg, MaxentModel model, SequenceValidator<T> validator, int cacheSize)
-
-
Method Detail
-
bestSequences
public Sequence[] bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext)
-
bestSequences
public Sequence[] bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext, double minSequenceScore)
Returns the best sequence of outcomes based on model for this object.- Parameters:
numSequences- The maximum number of sequences to be returned.sequence- The input sequence.additionalContext- An Object[] of additional context. This is passed to the context generator blindly with the assumption that the context are appropiate.minSequenceScore- A lower bound on the score of a returned sequence.- Returns:
- An array of the top ranked sequences of outcomes.
-
bestSequence
public Sequence bestSequence(T[] sequence, java.lang.Object[] additionalContext)
Returns the best sequence of outcomes based on model for this object.- Parameters:
sequence- The input sequence.additionalContext- An Object[] of additional context. This is passed to the context generator blindly with the assumption that the context are appropiate.- Returns:
- The top ranked sequence of outcomes or null if no sequence could be found
-
-