TokenNameFinderFactory (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.namefind, class: TokenNameFinderFactory

# Class TokenNameFinderFactory

java.lang.Object
opennlp.tools.util.BaseToolFactory
opennlp.tools.namefind.TokenNameFinderFactory

public class TokenNameFinderFactory extends BaseToolFactory
The factory that provides `TokenNameFinder` default implementations and resources. That only works if that's the central class used for training/runtime.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TokenNameFinderFactory()`
  Initializes a `TokenNameFinderFactory` that provides the default implementation of the resources.
  `TokenNameFinderFactory(byte[] featureGeneratorBytes, Map<String,Object> resources, SequenceCodec<String> seqCodec)`
  Initializes a `TokenNameFinderFactory` instance via given parameters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static TokenNameFinderFactory`
  `create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, SequenceCodec<String> seqCodec)`
  Initializes a `TokenNameFinderFactory` instance via given parameters.
  `NameContextGenerator`
  `createContextGenerator()`
  Creates and configures a new `NameContextGenerator` in a default combination.
  `AdaptiveFeatureGenerator`
  `createFeatureGenerators()`
  Creates the `AdaptiveFeatureGenerator`.
  `SequenceCodec<String>`
  `createSequenceCodec()`
  `static SequenceCodec<String>`
  `instantiateSequenceCodec(String sequenceCodecImplName)`
  Initializes a `SequenceCodec` instance via given parameters.
  `void`
  `validateArtifactMap()`
  Validates the parsed artifacts.

  ### Methods inherited from class BaseToolFactory

  `create, create, createArtifactMap, createArtifactSerializersMap, createManifestEntries`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### TokenNameFinderFactory

    public TokenNameFinderFactory()
    Initializes a `TokenNameFinderFactory` that provides the default implementation of the resources. `BioCodec` will be used as default `SequenceCodec`.

  - ### TokenNameFinderFactory

    public TokenNameFinderFactory(byte[] featureGeneratorBytes, Map<String,Object> resources, SequenceCodec<String> seqCodec)
    Initializes a `TokenNameFinderFactory` instance via given parameters.
    Parameters:
      `featureGeneratorBytes` - The `byte[]` representing the feature generator descriptor.
      `resources` - Additional resources in a mapping.
      `seqCodec` - The `SequenceCodec` to use.

- ## Method Details

  - ### create

    public static TokenNameFinderFactory create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, SequenceCodec<String> seqCodec) throws InvalidFormatException
    Initializes a `TokenNameFinderFactory` instance via given parameters.
    Parameters:
      `subclassName` - The class name used for instantiation. If `null`, an instance of `TokenNameFinderFactory` will be returned per default. Otherwise, the `ExtensionLoader` mechanism is applied to load the requested `subclassName`.
      `featureGeneratorBytes` - The `byte[]` representing the feature generator descriptor.
      `resources` - Additional resources in a mapping.
      `seqCodec` - The `SequenceCodec` to use.
    Returns:
      A valid `TokenNameFinderFactory` instance.
    Throws:
      `InvalidFormatException` - Thrown if the `ExtensionLoader` mechanism failed to create the factory associated with `subclassName`.

  - ### validateArtifactMap

    public void validateArtifactMap() throws InvalidFormatException
    Description copied from class: `BaseToolFactory`
    Validates the parsed artifacts.

    Note: Subclasses should generally invoke `super.validateArtifactMap` at the beginning of this method.

    Specified by:
      `validateArtifactMap` in class `BaseToolFactory`
    Throws:
      `InvalidFormatException` - Thrown if validation found invalid states.

  - ### createSequenceCodec

    public SequenceCodec<String> createSequenceCodec()
    Returns:
      Initializes and returns a `SequenceCodec` via its class name configured in a manifest. If that initialization fails (e.g., if no matching class could be loaded for the configured class name at runtime), the currently loaded (default) `SequenceCodec` is returned.
    See Also:
      - `BioCodec`
      - `BilouCodec`

  - ### createContextGenerator

    public NameContextGenerator createContextGenerator()
    Creates and configures a new `NameContextGenerator` in a default combination.
    Returns:
      A `NameContextGenerator` instance.
    See Also:
      - `DefaultNameContextGenerator`
      - `AdaptiveFeatureGenerator`

  - ### createFeatureGenerators

    public AdaptiveFeatureGenerator createFeatureGenerators()
    Creates the `AdaptiveFeatureGenerator`. Usually this is a set of generators contained in `AggregatedFeatureGenerator`.

    Note: The generators are created on every call to this method.

    Returns:
      The `AdaptiveFeatureGenerator` or `null` if there is no descriptor in the model.
    Throws:
      `TokenNameFinderModel.FeatureGeneratorCreationError` - Thrown if configuration errors occurred.
      `IllegalStateException` - Thrown if inconsistencies occurred during creation.

  - ### instantiateSequenceCodec

    public static SequenceCodec<String> instantiateSequenceCodec(String sequenceCodecImplName) throws InvalidFormatException
    Initializes a `SequenceCodec` instance via given parameters.
    Parameters:
      `sequenceCodecImplName` - The class name used for instantiation. If `null`, an instance of `BioCodec` will be returned per default. Otherwise, the `ExtensionLoader` mechanism is applied to load the requested `subclassName`.
    Returns:
      A valid `SequenceCodec` instance.
    Throws:
      `InvalidFormatException` - Thrown if the `ExtensionLoader` mechanism failed to create the codec associated with `sequenceCodecImplName`.
    See Also:
      - `SequenceCodec`
      - `BioCodec`
      - `BilouCodec`