Package opennlp.tools.ml
Class BeamSearch
java.lang.Object
opennlp.tools.ml.BeamSearch
- All Implemented Interfaces:
- SequenceClassificationModel
Performs k-best search over a sequence.
 
This is based on the description in Ratnaparkhi (1998), PhD diss, Univ. of Pennsylvania.
- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionBeamSearch(int size, MaxentModel model) Initializes aBeamSearchinstance.BeamSearch(int size, MaxentModel model, int cacheSize) Initializes aBeamSearchinstance.
- 
Method SummaryModifier and TypeMethodDescription<T> SequencebestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.<T> Sequence[]bestSequences(int numSequences, T[] sequence, Object[] additionalContext, double minSequenceScore, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.<T> Sequence[]bestSequences(int numSequences, T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.String[]
- 
Field Details- 
BEAM_SIZE_PARAMETER- See Also:
 
 
- 
- 
Constructor Details- 
BeamSearchInitializes aBeamSearchinstance.- Parameters:
- size- The size of the beam (k).
- model- The- MaxentModelfor assigning probabilities to the sequence outcomes.
 
- 
BeamSearchInitializes aBeamSearchinstance.- Parameters:
- size- The size of the beam (k).
- model- The- MaxentModelfor assigning probabilities to the sequence outcomes.
- cacheSize- The capacity of the- Cacheto use.
 
 
- 
- 
Method Details- 
bestSequencespublic <T> Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, double minSequenceScore, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.- Specified by:
- bestSequencesin interface- SequenceClassificationModel
- Parameters:
- numSequences- The number of sequences.
- sequence- The input- BeamSearchsequence.
- additionalContext- An- Objectof 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 generatorto use.
- validator- The- SequenceValidatorto validate sequences.
- Returns:
- The top ranked Sequenceof outcomes ornullif no sequence could be found.
 
- 
bestSequencespublic <T> Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.- Specified by:
- bestSequencesin interface- SequenceClassificationModel
- Parameters:
- numSequences- The number of sequences.
- sequence- The input- BeamSearchsequence.
- additionalContext- An- Objectof additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.
- cg- The- context generatorto use.
- validator- The- SequenceValidatorto validate sequences.
- Returns:
- The top ranked Sequenceof outcomes ornullif no sequence could be found.
 
- 
bestSequencepublic <T> Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.- Specified by:
- bestSequencein interface- SequenceClassificationModel
- Parameters:
- sequence- The input- BeamSearchsequence.
- additionalContext- An- Objectof additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.
- cg- The- context generatorto use.
- validator- The- SequenceValidatorto validate sequences.
- Returns:
- The top ranked Sequenceof outcomes ornullif no sequence could be found.
 
- 
getOutcomes- Specified by:
- getOutcomesin interface- SequenceClassificationModel
- Returns:
- Retrieves all possible outcomes.
 
 
-