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.String
BEAM_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 Sequence
bestSequence(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:
bestSequences
in 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:SequenceClassificationModel
Finds the n most probable sequences.- Specified by:
bestSequences
in interfaceSequenceClassificationModel<T>
- Returns:
-
bestSequence
public Sequence bestSequence(T[] sequence, java.lang.Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator)
Description copied from interface:SequenceClassificationModel
Finds the sequence with the highest probability.- Specified by:
bestSequence
in interfaceSequenceClassificationModel<T>
- Returns:
-
getOutcomes
public java.lang.String[] getOutcomes()
Description copied from interface:SequenceClassificationModel
Returns all possible outcomes.- Specified by:
getOutcomes
in interfaceSequenceClassificationModel<T>
- Returns:
-
-