Package opennlp.tools.chunker

# Class ThreadSafeChunkerME

java.lang.Object
opennlp.tools.chunker.ThreadSafeChunkerME

All Implemented Interfaces:
  `AutoCloseable`, `Chunker`

@ThreadSafe public class ThreadSafeChunkerME extends Object implements Chunker, AutoCloseable
A thread-safe version of the `ChunkerME`. Using it is completely transparent. You can use it in a single-threaded context as well, it only incurs a minimal overhead.

See Also:
  - `Chunker`
  - `ChunkerME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ThreadSafeChunkerME(ChunkerModel model)`
  Initializes a `ThreadSafeChunkerME` with the specified `model`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[]`
  `chunk(String[] toks, String[] tags)`
  Generates chunk tags for the given sequence returning the result in an array.
  `Span[]`
  `chunkAsSpans(String[] toks, String[] tags)`
  Generates tagged chunk `spans` for the given sequence returning the result in a `span` array.
  `void`
  `close()`
  `Sequence[]`
  `topKSequences(String[] sentence, String[] tags)`
  Computes the top k chunk `sequences` for the specified sentence with the specified pos-tags.
  `Sequence[]`
  `topKSequences(String[] sentence, String[] tags, double minSequenceScore)`
  Computes the top k chunk `sequences` for the specified sentence with the specified pos-tags.

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

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

- ## Constructor Details

  - ### ThreadSafeChunkerME

    public ThreadSafeChunkerME(ChunkerModel model)
    Initializes a `ThreadSafeChunkerME` with the specified `model`.
    Parameters:
      `model` - A valid `ChunkerModel`.

- ## Method Details

  - ### chunk

    public String[] chunk(String[] toks, String[] tags)
    Description copied from interface: `Chunker`
    Generates chunk tags for the given sequence returning the result in an array.
    Specified by:
      `chunk` in interface `Chunker`
    Parameters:
      `toks` - an array of the tokens or words of the sequence.
      `tags` - an array of the pos tags of the sequence.
    Returns:
      an array of chunk tags for each token in the sequence.

  - ### chunkAsSpans

    public Span[] chunkAsSpans(String[] toks, String[] tags)
    Description copied from interface: `Chunker`
    Generates tagged chunk `spans` for the given sequence returning the result in a `span` array.
    Specified by:
      `chunkAsSpans` in interface `Chunker`
    Parameters:
      `toks` - an array of the tokens or words of the sequence.
      `tags` - an array of the pos tags of the sequence.
    Returns:
      an array of `spans` with chunk tags for each chunk in the sequence.

  - ### topKSequences

    public Sequence[] topKSequences(String[] sentence, String[] tags)
    Description copied from interface: `Chunker`
    Computes the top k chunk `sequences` for the specified sentence with the specified pos-tags.
    Specified by:
      `topKSequences` in interface `Chunker`
    Parameters:
      `sentence` - The tokens of the sentence.
      `tags` - The pos-tags for the specified sentence.
    Returns:
      the top k chunk `sequences` for the specified sentence.

  - ### topKSequences

    public Sequence[] topKSequences(String[] sentence, String[] tags, double minSequenceScore)
    Description copied from interface: `Chunker`
    Computes the top k chunk `sequences` for the specified sentence with the specified pos-tags.
    Specified by:
      `topKSequences` in interface `Chunker`
    Parameters:
      `sentence` - The tokens of the sentence.
      `tags` - The pos-tags for the specified sentence.
      `minSequenceScore` - A lower bound on the score of a returned sequence.
    Returns:
      the top k chunk `sequences` for the specified sentence.

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`