Package opennlp.tools.ml
Class BeamSearch<T>
java.lang.Object
opennlp.tools.ml.BeamSearch<T>
- All Implemented Interfaces:
SequenceClassificationModel<T>
Performs k-best search over sequence. This is based on the description in
Ratnaparkhi (1998), PhD diss, Univ. of Pennsylvania.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBeamSearch(int size, MaxentModel model) Creates new search object.BeamSearch(int size, MaxentModel model, int cacheSize) -
Method Summary
Modifier and TypeMethodDescriptionbestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Finds the sequence with the highest probability.Sequence[]bestSequences(int numSequences, T[] sequence, 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, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Finds the n most probable sequences.String[]Returns all possible outcomes.
-
Field Details
-
BEAM_SIZE_PARAMETER
- See Also:
-
-
Constructor Details
-
BeamSearch
Creates new search object.- Parameters:
size- The size of the beam (k).model- the model for assigning probabilities to the sequence outcomes.
-
BeamSearch
-
-
Method Details
-
bestSequences
public Sequence[] bestSequences(int numSequences, T[] sequence, 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.cg-validator-- Returns:
- The top ranked sequence of outcomes or null if no sequence could be found
-
bestSequences
public Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Description copied from interface:SequenceClassificationModelFinds the n most probable sequences.- Specified by:
bestSequencesin interfaceSequenceClassificationModel<T>- Parameters:
sequence-additionalContext-cg-validator-- Returns:
-
bestSequence
public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Description copied from interface:SequenceClassificationModelFinds the sequence with the highest probability.- Specified by:
bestSequencein interfaceSequenceClassificationModel<T>- Parameters:
sequence-additionalContext-cg-validator-- Returns:
-
getOutcomes
Description copied from interface:SequenceClassificationModelReturns all possible outcomes.- Specified by:
getOutcomesin interfaceSequenceClassificationModel<T>- Returns:
-