Package opennlp.tools.postag

# Class POSSample

java.lang.Object
opennlp.tools.postag.POSSample

All Implemented Interfaces:
  `Serializable`, `Sample`

public class POSSample extends Object implements Sample
Represents an pos-tagged `sentence`.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `POSSample(String[] sentence, String[] tags)`
  Initializes a `POSSample` instance.
  `POSSample(String[] sentence, String[] tags, String[][] additionalContext)`
  Initializes a `POSSample` instance.
  `POSSample(List<String> sentence, List<String> tags)`
  Initializes a `POSSample` instance.
  `POSSample(List<String> sentence, List<String> tags, String[][] additionalContext)`
  Initializes a `POSSample` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String[][]`
  `getAdditionalContext()`
  `String[]`
  `getSentence()`
  `String[]`
  `getTags()`
  `int`
  `hashCode()`
  `static POSSample`
  `parse(String sentenceString)`
  Parses a `sentenceString`.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### POSSample

    public POSSample(String[] sentence, String[] tags)
    Initializes a `POSSample` instance.
    Parameters:
      `sentence` - The sentence of tokens to be tagged.
      `tags` - An array of pos tags for each token provided in `sentence`.

  - ### POSSample

    public POSSample(List<String> sentence, List<String> tags)
    Initializes a `POSSample` instance.
    Parameters:
      `sentence` - The sentence to be tagged.
      `tags` - A `List` of pos tags for each token provided in `sentence`.

  - ### POSSample

    public POSSample(List<String> sentence, List<String> tags, String[][] additionalContext)
    Initializes a `POSSample` instance.
    Parameters:
      `sentence` - The sentence to be tagged.
      `tags` - A `List` of pos tags for each token provided in `sentence`.
      `additionalContext` - A 2D array which holds additional information for the context.

  - ### POSSample

    public POSSample(String[] sentence, String[] tags, String[][] additionalContext)
    Initializes a `POSSample` instance.
    Parameters:
      `sentence` - The sentence to be tagged.
      `tags` - An array of pos tags for each token provided in `sentence`.
      `additionalContext` - A 2D array which holds additional information for the context.

- ## Method Details

  - ### getSentence

    public String[] getSentence()
    Returns:
      Retrieves the sentence as array.

  - ### getTags

    public String[] getTags()
    Returns:
      Retrieves the tags as array.

  - ### getAdditionalContext

    public String[][] getAdditionalContext()
    Returns:
      Retrieves additional information for the context.

  - ### toString

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

  - ### parse

    public static POSSample parse(String sentenceString) throws InvalidFormatException
    Parses a `sentenceString`.
    Parameters:
      `sentenceString` - The sentence to be parsed.
    Returns:
      A valid `POSSample` result.
    Throws:
      `InvalidFormatException` - Thrown if errors occurred during parsing.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`