Package opennlp.tools.postag

# Class DefaultPOSContextGenerator

java.lang.Object
opennlp.tools.postag.DefaultPOSContextGenerator

All Implemented Interfaces:
  `opennlp.tools.postag.POSContextGenerator`, `opennlp.tools.util.BeamSearchContextGenerator<String>`

public class DefaultPOSContextGenerator extends Object implements opennlp.tools.postag.POSContextGenerator
A default `context generator` for a `POSTagger`.

See Also:
  - `POSTagger`
  - `POSTaggerME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultPOSContextGenerator(int cacheSize, Dictionary dict)`
  Deprecated.
  Use `DefaultPOSContextGenerator(Dictionary)` instead.
  `DefaultPOSContextGenerator(Dictionary dict)`
  Initializes a `DefaultPOSContextGenerator` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[]`
  `getContext(int index, Object[] tokens, String[] tags)`
  Returns the context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.
  `String[]`
  `getContext(int index, String[] sequence, String[] priorDecisions, Object[] additionalContext)`
  Returns the context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.

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

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

- ## Constructor Details

  - ### DefaultPOSContextGenerator

    public DefaultPOSContextGenerator(Dictionary dict)
    Initializes a `DefaultPOSContextGenerator` instance. A cache size of `0` will be used as default.
    Parameters:
      `dict` - The `Dictionary` to be used.

  - ### DefaultPOSContextGenerator

    @Deprecated(since="3.0.0") public DefaultPOSContextGenerator(int cacheSize, Dictionary dict)
    Deprecated.
    Use `DefaultPOSContextGenerator(Dictionary)` instead.
    Initializes a `DefaultPOSContextGenerator` instance.
    Parameters:
      `cacheSize` - Ignored. The per-call cache has been removed for thread safety.
      `dict` - The `Dictionary` to be used.

- ## Method Details

  - ### getContext

    public String[] getContext(int index, String[] sequence, String[] priorDecisions, Object[] additionalContext)
    Returns the context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.
    Specified by:
      `getContext` in interface `opennlp.tools.util.BeamSearchContextGenerator<String>`
    Specified by:
      `getContext` in interface `opennlp.tools.postag.POSContextGenerator`
    Parameters:
      `index` - The index of the token for which the context is provided.
      `sequence` - The token sequence representing a sentence.
      `priorDecisions` - The tags assigned to the previous words in the sentence.
      `additionalContext` - The context for additional information.
    Returns:
      The context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.

  - ### getContext

    public String[] getContext(int index, Object[] tokens, String[] tags)
    Returns the context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.
    Parameters:
      `index` - The index of the token for which the context is provided.
      `tokens` - The tokens representing a sentence.
      `tags` - The tags assigned to the previous words in the sentence.
    Returns:
      The context for making a postag decision at the specified token `index` given the specified `tokens` and previous `tags`.