Sequence (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.util, class: Sequence

# 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
  Description
  `Sequence()`
  Initializes a new `Sequence` of outcomes.
  `Sequence(List<String> outcomes)`
  Initializes a new `Sequence` of outcomes from a list of `outcomes`.
  `Sequence(Sequence s)`
  Initializes a new `Sequence` of outcomes from an existing `Sequence`.
  `Sequence(Sequence s, String outcome, double p)`
  Initializes a new `Sequence` of outcomes from an existing `Sequence`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(String outcome, double p)`
  Adds an outcome and probability to this sequence.
  `int`
  `compareTo(Sequence s)`
  `boolean`
  `equals(Object obj)`
  `String`
  `getOutcome(int index)`
  `List<String>`
  `getOutcomes()`
  `double`
  `getProb(int index)`
  `double[]`
  `getProbs()`
  `void`
  `getProbs(double[] ps)`
  Populates an array with the probabilities associated with the `Sequence` outcomes.
  `double`
  `getScore()`
  `int`
  `getSize()`
  `int`
  `hashCode()`
  `String`
  `toString()`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### Sequence

    public Sequence()
    Initializes a new `Sequence` of outcomes.

  - ### Sequence

    public Sequence(Sequence s)
    Initializes a new `Sequence` of outcomes from an existing `Sequence`.
    Parameters:
      `s` - An existing `Sequence` used as input.

  - ### Sequence

    public Sequence(Sequence s, String outcome, double p)
    Initializes a new `Sequence` of outcomes from an existing `Sequence`.
    Parameters:
      `s` - An existing `Sequence` used as input.
      `outcome` - An extra outcome to add to `s`.
      `p` - A extra probability of the `outcome`.

  - ### Sequence

    public Sequence(List<String> outcomes)
    Initializes a new `Sequence` of outcomes from a list of `outcomes`. The probabilities for each outcome will be equally initialized to `ONE`.
    Parameters:
      `outcomes` - Several existing outcomes used as input.

- ## Method Details

  - ### 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:
      Retrieves a list of outcomes for this `Sequence`.

  - ### getSize

    public int getSize()
    Returns:
      Retrieves the size of the outcomes for this `Sequence`.

  - ### getOutcome

    public String getOutcome(int index)
    Parameters:
      `index` - must be greater than or equal to zero and must be less than `getSize()`.
    Returns:
      the outcome at the specified index.
    Throws:
      `IndexOutOfBoundsException` - thrown if the given index is out of range.

  - ### getProb

    public double getProb(int index)
    Parameters:
      `index` - must be greater than or equal to zero and must be less than `getSize()`.
    Returns:
      the probability at the specified index.
    Throws:
      `IndexOutOfBoundsException` - thrown if the given index is out of range.

  - ### getProbs

    public double[] getProbs()
    Returns:
      Retrieves an array of probabilities associated with the `Sequence` outcomes.

  - ### getScore

    public double getScore()
    Returns:
      Retrieves the score of this `Sequence`.

  - ### getProbs

    public void getProbs(double[] ps)
    Populates an array with the probabilities associated with the `Sequence` outcomes.
    Parameters:
      `ps` - A pre-allocated array to hold the values of the probabilities of the outcomes for this `Sequence`.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`