Package opennlp.tools.ml
Class BeamSearch<T>
- java.lang.Object
 - 
- opennlp.tools.ml.BeamSearch<T>
 
 
- 
- All Implemented Interfaces:
 SequenceClassificationModel<T>
public class BeamSearch<T> extends java.lang.Object implements SequenceClassificationModel<T>
Performs k-best search over 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 java.lang.StringBEAM_SIZE_PARAMETER 
- 
Constructor Summary
Constructors Constructor Description BeamSearch(int size, MaxentModel model)Creates new search object.BeamSearch(int size, MaxentModel model, int cacheSize) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SequencebestSequence(T[] sequence, java.lang.Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)Finds the sequence with the highest probability.Sequence[]bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext, double minSequenceScore, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)Returns the best sequence of outcomes based on model for this object.Sequence[]bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)Finds the n most probable sequences.java.lang.String[]getOutcomes()Returns all possible outcomes. 
 - 
 
- 
- 
Field Detail
- 
BEAM_SIZE_PARAMETER
public static final java.lang.String BEAM_SIZE_PARAMETER
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
BeamSearch
public BeamSearch(int size, MaxentModel model)Creates new search object.- Parameters:
 size- The size of the beam (k).model- the model for assigning probabilities to the sequence outcomes.
 
- 
BeamSearch
public BeamSearch(int size, MaxentModel model, int cacheSize) 
 - 
 
- 
Method Detail
- 
bestSequences
public Sequence[] bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext, double minSequenceScore, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)
Returns the best sequence of outcomes based on model for this object.- Specified by:
 bestSequencesin interfaceSequenceClassificationModel<T>- 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
 
 
- 
bestSequences
public Sequence[] bestSequences(int numSequences, T[] sequence, java.lang.Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)
Description copied from interface:SequenceClassificationModelFinds the n most probable sequences.- Specified by:
 bestSequencesin interfaceSequenceClassificationModel<T>- Returns:
 
 
- 
bestSequence
public Sequence bestSequence(T[] sequence, java.lang.Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)
Description copied from interface:SequenceClassificationModelFinds the sequence with the highest probability.- Specified by:
 bestSequencein interfaceSequenceClassificationModel<T>- Returns:
 
 
- 
getOutcomes
public java.lang.String[] getOutcomes()
Description copied from interface:SequenceClassificationModelReturns all possible outcomes.- Specified by:
 getOutcomesin interfaceSequenceClassificationModel<T>- Returns:
 
 
 - 
 
 -