Class SimplePerceptronSequenceTrainer

java.lang.Object
opennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.AbstractEventModelSequenceTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.perceptron.SimplePerceptronSequenceTrainer
All Implemented Interfaces:
opennlp.tools.commons.Trainer<opennlp.tools.util.TrainingParameters>, opennlp.tools.ml.EventModelSequenceTrainer<opennlp.tools.ml.model.Event, opennlp.tools.util.TrainingParameters>

public class SimplePerceptronSequenceTrainer extends opennlp.tools.ml.AbstractEventModelSequenceTrainer<opennlp.tools.util.TrainingParameters>
Trains models with 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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from interface opennlp.tools.ml.EventModelSequenceTrainer

    SEQUENCE_VALUE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a SimplePerceptronSequenceTrainer with a default configuration of training parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    opennlp.tools.ml.model.AbstractModel
    doTrain(opennlp.tools.ml.model.SequenceStream<opennlp.tools.ml.model.Event> events)
     
    void
    nextIteration(int iteration)
     
    opennlp.tools.ml.model.AbstractModel
    trainModel(int iterations, opennlp.tools.ml.model.SequenceStream<opennlp.tools.ml.model.Event> sequenceStream, int cutoff, boolean useAverage)
    Trains a PerceptronModel with given parameters.
    void

    Methods inherited from class opennlp.tools.ml.AbstractEventModelSequenceTrainer

    train

    Methods inherited from class opennlp.tools.ml.AbstractTrainer

    getAlgorithm, getCutoff, getIterations, getTrainingConfiguration, init, init

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface opennlp.tools.commons.Trainer

    init, init
  • Field Details

  • Constructor Details

    • SimplePerceptronSequenceTrainer

      public SimplePerceptronSequenceTrainer()
      Instantiates a SimplePerceptronSequenceTrainer with a default configuration of training parameters.
  • Method Details

    • validate

      public void validate()
      Overrides:
      validate in class opennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>
      Throws:
      IllegalArgumentException - Thrown if the algorithm name is not equal to {PERCEPTRON_SEQUENCE_VALUE}.
    • doTrain

      public opennlp.tools.ml.model.AbstractModel doTrain(opennlp.tools.ml.model.SequenceStream<opennlp.tools.ml.model.Event> events) throws IOException
      Specified by:
      doTrain in class opennlp.tools.ml.AbstractEventModelSequenceTrainer<opennlp.tools.util.TrainingParameters>
      Throws:
      IOException
    • trainModel

      public opennlp.tools.ml.model.AbstractModel trainModel(int iterations, opennlp.tools.ml.model.SequenceStream<opennlp.tools.ml.model.Event> sequenceStream, int cutoff, boolean useAverage) throws IOException
      Trains a PerceptronModel with given parameters.
      Parameters:
      iterations - The number of iterations to use for training.
      sequenceStream - The opennlp.tools.ml.model.SequenceStream<opennlp.tools.ml.model.Event> used as data input.
      cutoff - The {Parameters.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