Class BeamSearch
java.lang.Object
opennlp.tools.ml.BeamSearch
- All Implemented Interfaces:
opennlp.tools.ml.model.SequenceClassificationModel
public class BeamSearch
extends Object
implements opennlp.tools.ml.model.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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBeamSearch(int size, opennlp.tools.ml.model.MaxentModel model) Initializes aBeamSearchinstance.BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model, int cacheSize) Initializes aBeamSearchinstance. -
Method Summary
Modifier and TypeMethodDescription<T> opennlp.tools.util.SequencebestSequence(T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.<T> opennlp.tools.util.Sequence[]bestSequences(int numSequences, T[] sequence, Object[] additionalContext, double minSequenceScore, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.<T> opennlp.tools.util.Sequence[]bestSequences(int numSequences, T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.String[]
-
Field Details
-
BEAM_SIZE_PARAMETER
- See Also:
-
-
Constructor Details
-
BeamSearch
public BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model) Initializes aBeamSearchinstance.- Parameters:
size- The size of the beam (k).model- TheMaxentModelfor assigning probabilities to the sequence outcomes.
-
BeamSearch
public BeamSearch(int size, opennlp.tools.ml.model.MaxentModel model, int cacheSize) Initializes aBeamSearchinstance.- Parameters:
size- The size of the beam (k).model- TheMaxentModelfor assigning probabilities to the sequence outcomes.cacheSize- The capacity of theCacheto use.
-
-
Method Details
-
bestSequences
public <T> opennlp.tools.util.Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, double minSequenceScore, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.- Specified by:
bestSequencesin interfaceopennlp.tools.ml.model.SequenceClassificationModel- Parameters:
numSequences- The number of sequences.sequence- The inputTsequence.additionalContext- AnObjectof 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- Thecontext generatorto use.validator- TheSequenceValidatorto validate sequences.- Returns:
- The top ranked
Sequenceof outcomes ornullif no sequence could be found.
-
bestSequences
public <T> opennlp.tools.util.Sequence[] bestSequences(int numSequences, T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.- Specified by:
bestSequencesin interfaceopennlp.tools.ml.model.SequenceClassificationModel- Parameters:
numSequences- The number of sequences.sequence- The inputTsequence.additionalContext- AnObjectof additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.cg- Thecontext generatorto use.validator- TheSequenceValidatorto validate sequences.- Returns:
- The top ranked
Sequenceof outcomes ornullif no sequence could be found.
-
bestSequence
public <T> opennlp.tools.util.Sequence bestSequence(T[] sequence, Object[] additionalContext, opennlp.tools.util.BeamSearchContextGenerator<T> cg, opennlp.tools.util.SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel.- Specified by:
bestSequencein interfaceopennlp.tools.ml.model.SequenceClassificationModel- Parameters:
sequence- The inputTsequence.additionalContext- AnObjectof additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.cg- Thecontext generatorto use.validator- TheSequenceValidatorto validate sequences.- Returns:
- The top ranked
Sequenceof outcomes ornullif no sequence could be found.
-
getOutcomes
- Specified by:
getOutcomesin interfaceopennlp.tools.ml.model.SequenceClassificationModel
-