Package opennlp.tools.ml.perceptron
Class SimplePerceptronSequenceTrainer
- java.lang.Object
 - 
- opennlp.tools.ml.AbstractTrainer
 - 
- opennlp.tools.ml.AbstractEventModelSequenceTrainer
 - 
- opennlp.tools.ml.perceptron.SimplePerceptronSequenceTrainer
 
 
 
 
- 
- All Implemented Interfaces:
 Trainer,EventModelSequenceTrainer<Event>
public class SimplePerceptronSequenceTrainer extends AbstractEventModelSequenceTrainer
Trainsmodelswith sequences using the perceptron algorithm.Each outcome is represented as a binary perceptron classifier. This supports standard (integer) weighting as well average weighting.
Sequence information is used in a simplified was to that described in: Discriminative Training Methods for Hidden Markov Models: Theory and Experiments with the Perceptron Algorithm. Michael Collins, EMNLP 2002.
Specifically only updates are applied to tokens which were incorrectly tagged by a sequence tagger rather than to all feature across the sequence which differ from the training sequence.
- See Also:
 PerceptronModel,AbstractEventModelSequenceTrainer
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static StringPERCEPTRON_SEQUENCE_VALUE- 
Fields inherited from class opennlp.tools.ml.AbstractTrainer
ALGORITHM_PARAM, CUTOFF_DEFAULT, CUTOFF_PARAM, ITERATIONS_DEFAULT, ITERATIONS_PARAM, TRAINER_TYPE_PARAM, VERBOSE_DEFAULT, VERBOSE_PARAM 
- 
Fields inherited from interface opennlp.tools.ml.EventModelSequenceTrainer
SEQUENCE_VALUE 
 - 
 
- 
Constructor Summary
Constructors Constructor Description SimplePerceptronSequenceTrainer()Instantiates aSimplePerceptronSequenceTrainerwith a default configuration of training parameters. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AbstractModeldoTrain(SequenceStream<Event> events)booleanisValid()Deprecated.Usevalidate()instead.voidnextIteration(int iteration)AbstractModeltrainModel(int iterations, SequenceStream<Event> sequenceStream, int cutoff, boolean useAverage)Trains aPerceptronModelwith given parameters.voidvalidate()Checks the configuredparameters.- 
Methods inherited from class opennlp.tools.ml.AbstractEventModelSequenceTrainer
train 
- 
Methods inherited from class opennlp.tools.ml.AbstractTrainer
getAlgorithm, getCutoff, getIterations, init, init 
 - 
 
 - 
 
- 
- 
Field Detail
- 
PERCEPTRON_SEQUENCE_VALUE
public static final String PERCEPTRON_SEQUENCE_VALUE
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
SimplePerceptronSequenceTrainer
public SimplePerceptronSequenceTrainer()
Instantiates aSimplePerceptronSequenceTrainerwith a default configuration of training parameters. 
 - 
 
- 
Method Detail
- 
validate
public void validate()
Checks the configuredparameters. If a subclass overrides this, it should callsuper.validate();.- Overrides:
 validatein classAbstractTrainer- Throws:
 IllegalArgumentException- Thrown if the algorithm name is not equal to {PERCEPTRON_SEQUENCE_VALUE}.
 
- 
isValid
@Deprecated public boolean isValid()
Deprecated.Usevalidate()instead.- Overrides:
 isValidin classAbstractTrainer- Returns:
 trueif the validation of the internal configuration succeeds,falseotherwise.
 
- 
doTrain
public AbstractModel doTrain(SequenceStream<Event> events) throws IOException
- Specified by:
 doTrainin classAbstractEventModelSequenceTrainer- Throws:
 IOException
 
- 
trainModel
public AbstractModel trainModel(int iterations, SequenceStream<Event> sequenceStream, int cutoff, boolean useAverage) throws IOException
Trains aPerceptronModelwith given parameters.- Parameters:
 iterations- The number of iterations to use for training.sequenceStream- TheSequenceStreamused as data input.cutoff- The {AbstractTrainer.CUTOFF_PARAM} value to use for training.useAverage- Whether to use 'averaging', or not.- Returns:
 - A valid, trained 
perceptron model. - Throws:
 IOException
 
- 
nextIteration
public void nextIteration(int iteration) throws IOException- Throws:
 IOException
 
 - 
 
 -