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

Package opennlp.tools.namefind

# Class NameSample

java.lang.Object
opennlp.tools.namefind.NameSample

All Implemented Interfaces:
  `Serializable`, `Sample`

public class NameSample extends Object implements Sample
Encapsulates names for a single unit of text.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_TYPE`
  The default type value when there is no type in training data.
  `static final String`
  `END_TAG`
  `static final String`
  `START_TAG`
  `static final String`
  `START_TAG_PREFIX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NameSample(String[] sentence, Span[] names, boolean clearAdaptiveData)`
  Initializes a `NameSample` instance with given parameters.
  `NameSample(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData)`
  Initializes a `NameSample` instance with given parameters.
  `NameSample(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData)`
  Initializes a `NameSample` instance with given parameters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String[][]`
  `getAdditionalContext()`
  `String`
  `getId()`
  `Span[]`
  `getNames()`
  `String[]`
  `getSentence()`
  `int`
  `hashCode()`
  `boolean`
  `isClearAdaptiveDataSet()`
  `static NameSample`
  `parse(String taggedTokens, boolean clearAdaptiveData)`
  Parses given input into a `NameSample`.
  `static NameSample`
  `parse(String taggedTokens, String defaultType, boolean clearAdaptiveData)`
  Parses given input into a `NameSample`.
  `String`
  `toString()`

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

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

- ## Field Details

  - ### START_TAG_PREFIX

    public static final String START_TAG_PREFIX
    See Also:
      - Constant Field Values

  - ### START_TAG

    public static final String START_TAG
    See Also:
      - Constant Field Values

  - ### END_TAG

    public static final String END_TAG
    See Also:
      - Constant Field Values

  - ### DEFAULT_TYPE

    public static final String DEFAULT_TYPE
    The default type value when there is no type in training data.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### NameSample

    public NameSample(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData)
    Initializes a `NameSample` instance with given parameters.
    Parameters:
      `id` - The identifier to use.
      `sentence` - The tokens representing a training sentence. Must not be `null`.
      `names` - The `names` to use.
      `additionalContext` - Additional context in a 2-dimensional array.
      `clearAdaptiveData` - If `true` the adaptive data of the feature generators is cleared.
    Throws:
      `RuntimeException` - Thrown if name spans are overlapping.

  - ### NameSample

    public NameSample(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData)
    Initializes a `NameSample` instance with given parameters.
    Parameters:
      `sentence` - The tokens representing a sentence. Must not be `null`.
      `names` - The `names` to use.
      `additionalContext` - Additional context in a 2-dimensional array.
      `clearAdaptiveData` - If `true` the adaptive data of the feature generators is cleared.
    Throws:
      `RuntimeException` - Thrown if name spans are overlapping.

  - ### NameSample

    public NameSample(String[] sentence, Span[] names, boolean clearAdaptiveData)
    Initializes a `NameSample` instance with given parameters.
    Parameters:
      `sentence` - The tokens representing a sentence. Must not be `null`.
      `names` - The `names` to use.
      `clearAdaptiveData` - If `true` the adaptive data of the feature generators is cleared.
    Throws:
      `RuntimeException` - Thrown if name spans are overlapping.

- ## Method Details

  - ### getId

    public String getId()
    Returns:
      Retrieves the current identifier. May be `null`.

  - ### getSentence

    public String[] getSentence()
    Returns:
      Retrieves the sentence in tokenized form.

  - ### getNames

    public Span[] getNames()
    Returns:
      Retrieves the `names`.

  - ### getAdditionalContext

    public String[][] getAdditionalContext()
    Returns:
      Retrieves additional context. May be `null`.

  - ### isClearAdaptiveDataSet

    public boolean isClearAdaptiveDataSet()
    Returns:
      `true` if the adaptive data of the feature generators are cleared, `false` otherwise.

  - ### hashCode

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

  - ### equals

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

  - ### toString

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

  - ### parse

    public static NameSample parse(String taggedTokens, boolean clearAdaptiveData) throws IOException
    Parses given input into a `NameSample`.
    Parameters:
      `taggedTokens` - The input data to parse.
      `clearAdaptiveData` - `true` if the adaptive data of the feature generators should be cleared, `false` otherwise.
    Returns:
      A `NameSample` instance resulting from the parsing.
    Throws:
      `IOException` - Thrown if IO errors occurred during parsing.

  - ### parse

    public static NameSample parse(String taggedTokens, String defaultType, boolean clearAdaptiveData) throws IOException
    Parses given input into a `NameSample`.
    Parameters:
      `taggedTokens` - The input data to parse.
      `defaultType` - The type to set by default.
      `clearAdaptiveData` - `true` if the adaptive data of the feature generators should be cleared, `false` otherwise.
    Returns:
      A `NameSample` instance resulting from the parsing.
    Throws:
      `IOException` - Thrown if IO errors occurred during parsing.