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:
    EventModelSequenceTrainer

      public class SimplePerceptronSequenceTrainer
      extends AbstractEventModelSequenceTrainer

  Trains models for 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.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PERCEPTRON_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 and Description
    `SimplePerceptronSequenceTrainer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `AbstractModel` | `doTrain(SequenceStream events)`
    `boolean` | `isValid()` Deprecated.
    `void` | `nextIteration(int iteration)`
    `AbstractModel` | `trainModel(int iterations, SequenceStream sequenceStream, int cutoff, boolean useAverage)`
    `void` | `validate()` Check parameters.

    - ### Methods inherited from class opennlp.tools.ml.AbstractEventModelSequenceTrainer

      `train`

    - ### Methods inherited from class opennlp.tools.ml.AbstractTrainer

      `getAlgorithm, getCutoff, getIterations, init, init`

    - ### Methods inherited from class java.lang.Object

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

    - ### Methods inherited from interface opennlp.tools.ml.EventModelSequenceTrainer

      `init, init`

- - ### Field Detail

    - #### PERCEPTRON_SEQUENCE_VALUE

          public static final String PERCEPTRON_SEQUENCE_VALUE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SimplePerceptronSequenceTrainer

          public SimplePerceptronSequenceTrainer()

  - ### Method Detail

    - #### validate

          public void validate()

      Description copied from class: `AbstractTrainer`
      Check parameters. If subclass overrides this, it should call super.validate();
      Overrides:
        `validate` in class `AbstractTrainer`

    - #### isValid

          @Deprecated
          public boolean isValid()

      Deprecated.
      Overrides:
        `isValid` in class `AbstractTrainer`
      Returns:

    - #### doTrain

          public AbstractModel doTrain(SequenceStream events)
                                throws IOException

      Specified by:
        `doTrain` in class `AbstractEventModelSequenceTrainer`
      Throws:
        `IOException`

    - #### trainModel

          public AbstractModel trainModel(int iterations,
                                          SequenceStream sequenceStream,
                                          int cutoff,
                                          boolean useAverage)
                                   throws IOException

      Throws:
        `IOException`

    - #### nextIteration

          public void nextIteration(int iteration)
                             throws IOException

      Throws:
        `IOException`

Copyright © 2026 The Apache Software Foundation. All rights reserved.