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 a sequence.
This is based on the description in Ratnaparkhi (1998), PhD diss, Univ. of Pennsylvania.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionBeamSearch
(int size, MaxentModel model) Initializes aBeamSearch
instance.BeamSearch
(int size, MaxentModel model, int cacheSize) Initializes aBeamSearch
instance. -
Method Summary
Modifier and TypeMethodDescriptionbestSequence
(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel
.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
.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
-
BeamSearch
Initializes aBeamSearch
instance.- Parameters:
size
- The size of the beam (k).model
- TheMaxentModel
for assigning probabilities to the sequence outcomes.
-
BeamSearch
Initializes aBeamSearch
instance.- Parameters:
size
- The size of the beam (k).model
- TheMaxentModel
for assigning probabilities to the sequence outcomes.cacheSize
- The capacity of theCache
to use.
-
-
Method Details
-
bestSequences
public 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:
bestSequences
in interfaceSequenceClassificationModel<T>
- Parameters:
numSequences
- The number of sequences.sequence
- The inputBeamSearch
sequence.additionalContext
- AnObject
of 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 generator
to use.validator
- TheSequenceValidator
to validate sequences.- Returns:
- The top ranked
Sequence
of outcomes ornull
if no sequence could be found.
-
bestSequences
public 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:
bestSequences
in interfaceSequenceClassificationModel<T>
- Parameters:
numSequences
- The number of sequences.sequence
- The inputBeamSearch
sequence.additionalContext
- AnObject
of additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.cg
- Thecontext generator
to use.validator
- TheSequenceValidator
to validate sequences.- Returns:
- The top ranked
Sequence
of outcomes ornull
if no sequence could be found.
-
bestSequence
public Sequence bestSequence(T[] sequence, Object[] additionalContext, BeamSearchContextGenerator<T> cg, SequenceValidator<T> validator) Computes the best sequence of outcomes based on theMaxentModel
.- Specified by:
bestSequence
in interfaceSequenceClassificationModel<T>
- Parameters:
sequence
- The inputBeamSearch
sequence.additionalContext
- AnObject
of additional context. This is passed to the context generator blindly with the assumption that the context are appropriate.cg
- Thecontext generator
to use.validator
- TheSequenceValidator
to validate sequences.- Returns:
- The top ranked
Sequence
of outcomes ornull
if no sequence could be found.
-
getOutcomes
- Specified by:
getOutcomes
in interfaceSequenceClassificationModel<T>
- Returns:
- Retrieves all possible outcomes.
-