opennlp.tools.namefind

## Class NameSample

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

- All Implemented Interfaces:
    Serializable

      public class NameSample
      extends Object
      implements Serializable

  Class for holding names for a single unit of text.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_TYPE` The a default type value when there is no type in training data.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NameSample(String[] sentence, Span[] names, boolean clearAdaptiveData)`
    `NameSample(String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData)` Initializes the current instance.
    `NameSample(String id, String[] sentence, Span[] names, String[][] additionalContext, boolean clearAdaptiveData)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `String[][]` | `getAdditionalContext()`
    `String` | `getId()`
    `Span[]` | `getNames()`
    `String[]` | `getSentence()`
    `int` | `hashCode()`
    `boolean` | `isClearAdaptiveDataSet()`
    `static NameSample` | `parse(String taggedTokens, boolean isClearAdaptiveData)`
    `static NameSample` | `parse(String taggedTokens, String defaultType, boolean isClearAdaptiveData)`
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### DEFAULT_TYPE

          public static final String DEFAULT_TYPE

      The a default type value when there is no type in training data.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NameSample

          public NameSample(String id,
                            String[] sentence,
                            Span[] names,
                            String[][] additionalContext,
                            boolean clearAdaptiveData)

    - #### NameSample

          public NameSample(String[] sentence,
                            Span[] names,
                            String[][] additionalContext,
                            boolean clearAdaptiveData)

      Initializes the current instance.
      Parameters:
        `sentence` - training sentence
        `names` -
        `additionalContext` -
        `clearAdaptiveData` - if true the adaptive data of the feature generators is cleared

    - #### NameSample

          public NameSample(String[] sentence,
                            Span[] names,
                            boolean clearAdaptiveData)

  - ### Method Detail

    - #### getId

          public String getId()

    - #### getSentence

          public String[] getSentence()

    - #### getNames

          public Span[] getNames()

    - #### getAdditionalContext

          public String[][] getAdditionalContext()

    - #### isClearAdaptiveDataSet

          public boolean isClearAdaptiveDataSet()

    - #### 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 isClearAdaptiveData)
                                  throws IOException

      Throws:
        `IOException`

    - #### parse

          public static NameSample parse(String taggedTokens,
                                         String defaultType,
                                         boolean isClearAdaptiveData)
                                  throws IOException

      Throws:
        `IOException`

Copyright © 2026 The Apache Software Foundation. All rights reserved.