ChunkSample (Apache OpenNLP :: API 3.0.0-M4 API)
Description: declaration: package: opennlp.tools.chunker, class: ChunkSample

Package opennlp.tools.chunker

# Class ChunkSample

java.lang.Object
opennlp.tools.chunker.ChunkSample

All Implemented Interfaces:
  `Serializable`, `Sample`

public class ChunkSample extends Object implements Sample
Class for holding chunks for a single unit of text.

See Also:
  - Serialized Form

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `Span[]`
  `getPhrasesAsSpanList()`
  `String[]`
  `getPreds()`
  `String[]`
  `getSentence()`
  `String[]`
  `getTags()`
  `int`
  `hashCode()`
  `String`
  `nicePrint()`
  Creates a nice to read string for the phrases formatted as following:
  `[NP Rockwell_NNP ] [VP said_VBD ] [NP the_DT agreement_NN ] [VP calls_VBZ ] [SBAR for_IN ] [NP it_PRP ] [VP to_TO supply_VB ] [NP 200_CD additional_JJ so-called_JJ shipsets_NNS ] [PP for_IN ] [NP the_DT planes_NNS ] ._.`
  `static Span[]`
  `phrasesAsSpanList(String[] aSentence, String[] aTags, String[] aPreds)`
  Create arrays of `spans` of phrases.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### ChunkSample

    public ChunkSample(String[] sentence, String[] tags, String[] preds)
    Initializes a `ChunkSample` instance.
    Parameters:
      `sentence` - The training sentence.
      `tags` - The POS tags for the `sentence`.
      `preds` - The chunk tags in B-* I-* notation.

  - ### ChunkSample

    public ChunkSample(List<String> sentence, List<String> tags, List<String> preds)
    Initializes a `ChunkSample` instance.
    Parameters:
      `sentence` - The training sentence.
      `tags` - The POS tags for the `sentence`.
      `preds` - The chunk tags in B-* I-* notation.

- ## Method Details

  - ### getSentence

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

  - ### getTags

    public String[] getTags()
    Returns:
      Retrieves the POS Tags for the sentence.

  - ### getPreds

    public String[] getPreds()
    Returns:
      Retrieves the chunk tags in B-* I-* notation.

  - ### getPhrasesAsSpanList

    public Span[] getPhrasesAsSpanList()
    Returns:
      the phrases as an array of spans.

  - ### phrasesAsSpanList

    public static Span[] phrasesAsSpanList(String[] aSentence, String[] aTags, String[] aPreds)
    Create arrays of `spans` of phrases.
    Parameters:
      `aSentence` - The training sentence.
      `aTags` - The POS tags for the `sentence`.
      `aPreds` - The chunk tags in B-* I-* notation.
    Returns:
      the phrases as an array of spans

  - ### nicePrint

    public String nicePrint()
    Creates a nice to read string for the phrases formatted as following:
    `[NP Rockwell_NNP ] [VP said_VBD ] [NP the_DT agreement_NN ] [VP calls_VBZ ] [SBAR for_IN ] [NP it_PRP ] [VP to_TO supply_VB ] [NP 200_CD additional_JJ so-called_JJ shipsets_NNS ] [PP for_IN ] [NP the_DT planes_NNS ] ._.`
    Returns:
      A nice to read string representation of the chunk phases

  - ### toString

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

  - ### hashCode

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

  - ### equals

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