opennlp.tools.util

## Class Sequence

- java.lang.Object
- - opennlp.tools.util.Sequence

- All Implemented Interfaces:
    Comparable<Sequence>

      public class Sequence
      extends Object
      implements Comparable<Sequence>

  Represents a weighted sequence of outcomes.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Sequence()` Creates a new sequence of outcomes.
    `Sequence(List<String> outcomes)`
    `Sequence(Sequence s)`
    `Sequence(Sequence s, String outcome, double p)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(String outcome, double p)` Adds an outcome and probability to this sequence.
    `int` | `compareTo(Sequence s)`
    `boolean` | `equals(Object obj)`
    `List<String>` | `getOutcomes()` Returns a list of outcomes for this sequence.
    `double[]` | `getProbs()` Returns an array of probabilities associated with the outcomes of this sequence.
    `void` | `getProbs(double[] ps)` Populates an array with the probabilities associated with the outcomes of this sequence.
    `double` | `getScore()` Returns the score of this sequence.
    `int` | `hashCode()`
    `String` | `toString()`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Sequence

          public Sequence()

      Creates a new sequence of outcomes.

    - #### Sequence

          public Sequence(Sequence s)

    - #### Sequence

          public Sequence(Sequence s,
                          String outcome,
                          double p)

    - #### Sequence

          public Sequence(List<String> outcomes)

  - ### Method Detail

    - #### compareTo

          public int compareTo(Sequence s)

      Specified by:
        `compareTo` in interface `Comparable<Sequence>`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### add

          public void add(String outcome,
                          double p)

      Adds an outcome and probability to this sequence.
      Parameters:
        `outcome` - the outcome to be added.
        `p` - the probability associated with this outcome.

    - #### getOutcomes

          public List<String> getOutcomes()

      Returns a list of outcomes for this sequence.
      Returns:
        a list of outcomes.

    - #### getProbs

          public double[] getProbs()

      Returns an array of probabilities associated with the outcomes of this sequence.
      Returns:
        an array of probabilities.

    - #### getScore

          public double getScore()

      Returns the score of this sequence.
      Returns:
        The score of this sequence.

    - #### getProbs

          public void getProbs(double[] ps)

      Populates an array with the probabilities associated with the outcomes of this sequence.
      Parameters:
        `ps` - a pre-allocated array to use to hold the values of the probabilities of the outcomes for this sequence.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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