Package opennlp.tools.namefind

# Class TokenNameFinderModel

java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.namefind.TokenNameFinderModel

All Implemented Interfaces:
  `Serializable`, `opennlp.tools.util.model.ArtifactProvider`

public class TokenNameFinderModel extends BaseModel
The `TokenNameFinderModel` is the model used by a learnable `TokenNameFinder`.

See Also:
  - `NameFinderME`
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `TokenNameFinderModel.FeatureGeneratorCreationError`

- ## Field Summary

  ### Fields inherited from class opennlp.tools.util.model.BaseModel

  `TRAINING_CUTOFF_PROPERTY, TRAINING_EVENTHASH_PROPERTY, TRAINING_ITERATIONS_PROPERTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TokenNameFinderModel(File modelFile)`
  Initializes a `TokenNameFinderModel` instance via a valid `File`.
  `TokenNameFinderModel(InputStream in)`
  Initializes a `TokenNameFinderModel` instance via a valid `InputStream`.
  `TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries)`
  Initializes a `TokenNameFinderModel` instance via given parameters.
  `TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries)`
  Initializes a `TokenNameFinderModel` instance via given parameters.
  `TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries, opennlp.tools.util.SequenceCodec<String> seqCodec, TokenNameFinderFactory factory)`
  Initializes a `TokenNameFinderModel` instance via given parameters.
  `TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, Map<String,Object> resources, Map<String,String> manifestInfoEntries)`
  Initializes a `TokenNameFinderModel` instance via given parameters.
  `TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.SequenceClassificationModel nameFinderModel, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries, opennlp.tools.util.SequenceCodec<String> seqCodec, TokenNameFinderFactory factory)`
  Initializes a `TokenNameFinderModel` instance via given parameters.
  `TokenNameFinderModel(URL modelURL)`
  Initializes a `TokenNameFinderModel` instance via a valid `URL`.
  `TokenNameFinderModel(Path modelPath)`
  Initializes a `TokenNameFinderModel` instance via a valid `Path`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Map<String,opennlp.tools.util.model.ArtifactSerializer<?>>`
  `createArtifactSerializers()`
  Create the `serializers`.
  `TokenNameFinderFactory`
  `getFactory()`
  `opennlp.tools.ml.model.SequenceClassificationModel`
  `getNameFinderSequenceModel()`
  `opennlp.tools.util.SequenceCodec<String>`
  `getSequenceCodec()`

  ### Methods inherited from class opennlp.tools.util.model.BaseModel

  `getArtifact, getLanguage, getManifestProperty, getVersion, isLoadedFromSerialized, serialize, serialize, serialize`

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

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

- ## Constructor Details

  - ### TokenNameFinderModel

    public TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.SequenceClassificationModel nameFinderModel, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries, opennlp.tools.util.SequenceCodec<String> seqCodec, TokenNameFinderFactory factory)
    Initializes a `TokenNameFinderModel` instance via given parameters.
    Parameters:
      `languageCode` - The ISO conform language code.
      `nameFinderModel` - A valid `MaxentModel`.
      `generatorDescriptor` - The `byte[]` representing the feature generator descriptor.
      `resources` - Additional resources in a mapping.
      `manifestInfoEntries` - Additional information kept in the manifest.
      `seqCodec` - The `SequenceCodec` to use.
      `factory` - The `TokenNameFinderFactory` for creating related objects.
    Throws:
      `IllegalArgumentException` - Thrown if the `namFinderModel` incompatible with `seqCodec`.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries, opennlp.tools.util.SequenceCodec<String> seqCodec, TokenNameFinderFactory factory)
    Initializes a `TokenNameFinderModel` instance via given parameters.
    Parameters:
      `languageCode` - The ISO conform language code.
      `nameFinderModel` - A valid `MaxentModel`.
      `beamSize` - The beam size. Must be greater than `0`.
      `generatorDescriptor` - The `byte[]` representing the feature generator descriptor.
      `resources` - Additional resources in a mapping.
      `manifestInfoEntries` - Additional information kept in the manifest.
      `seqCodec` - The `SequenceCodec` to use.
      `factory` - The `TokenNameFinderFactory` for creating related objects.
    Throws:
      `IllegalArgumentException` - Thrown if the `namFinderModel` incompatible with `seqCodec`.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries)
    Initializes a `TokenNameFinderModel` instance via given parameters.
    Parameters:
      `languageCode` - The ISO conform language code.
      `nameFinderModel` - A valid `MaxentModel`.
      `generatorDescriptor` - The `byte[]` representing the feature generator descriptor.
      `resources` - Additional resources in a mapping.
      `manifestInfoEntries` - Additional information kept in the manifest.
    Throws:
      `IllegalArgumentException` - Thrown if the `namFinderModel` incompatible with `seqCodec`.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, int beamSize, byte[] generatorDescriptor, Map<String,Object> resources, Map<String,String> manifestInfoEntries)
    Initializes a `TokenNameFinderModel` instance via given parameters.
    Parameters:
      `languageCode` - The ISO conform language code.
      `nameFinderModel` - A valid `MaxentModel`.
      `beamSize` - The beam size. Must be greater than `0`.
      `generatorDescriptor` - The `byte[]` representing the feature generator descriptor.
      `resources` - Additional resources in a mapping.
      `manifestInfoEntries` - Additional information kept in the manifest.
    Throws:
      `IllegalArgumentException` - Thrown if the `namFinderModel` incompatible with `seqCodec`.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(String languageCode, opennlp.tools.ml.model.MaxentModel nameFinderModel, Map<String,Object> resources, Map<String,String> manifestInfoEntries)
    Initializes a `TokenNameFinderModel` instance via given parameters.
    Parameters:
      `languageCode` - The ISO conform language code.
      `nameFinderModel` - A valid `MaxentModel`.
      `resources` - Additional resources in a mapping.
      `manifestInfoEntries` - Additional information kept in the manifest.
    Throws:
      `IllegalArgumentException` - Thrown if the `nameFinderModel` is incompatible with `seqCodec`.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(InputStream in) throws IOException
    Initializes a `TokenNameFinderModel` instance via a valid `InputStream`.
    Parameters:
      `in` - The `InputStream` used for loading the model.
    Throws:
      `IOException` - Thrown if IO errors occurred during initialization.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(File modelFile) throws IOException
    Initializes a `TokenNameFinderModel` instance via a valid `File`.
    Parameters:
      `modelFile` - The `File` used for loading the model.
    Throws:
      `IOException` - Thrown if IO errors occurred during initialization.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(Path modelPath) throws IOException
    Initializes a `TokenNameFinderModel` instance via a valid `Path`.
    Parameters:
      `modelPath` - The `Path` used for loading the model.
    Throws:
      `IOException` - Thrown if IO errors occurred during initialization.

  - ### TokenNameFinderModel

    public TokenNameFinderModel(URL modelURL) throws IOException
    Initializes a `TokenNameFinderModel` instance via a valid `URL`.
    Parameters:
      `modelURL` - The `URL` used for loading the model.
    Throws:
      `IOException` - Thrown if IO errors occurred during initialization.

- ## Method Details

  - ### getNameFinderSequenceModel

    public opennlp.tools.ml.model.SequenceClassificationModel getNameFinderSequenceModel()
    Returns:
      Retrieves a valid `SequenceClassificationModel` or `null` if no matching one could be found.

  - ### getSequenceCodec

    public opennlp.tools.util.SequenceCodec<String> getSequenceCodec()
    Returns:
      Retrieves the `SequenceCodec` in use.

  - ### getFactory

    public TokenNameFinderFactory getFactory()
    Returns:
      Retrieves the `TokenNameFinderFactory` in use.

  - ### createArtifactSerializers

    public static Map<String,opennlp.tools.util.model.ArtifactSerializer<?>> createArtifactSerializers()
    Create the `serializers`. Currently, for serializers related to features that require external resources, such as `W2VClassesDictionary` objects, the convention is to add its element tag name as key of the serializer map.

    For example, the element tag name for the `WordClusterFeatureGenerator` which uses `W2VClassesDictionary` objects serialized by the `W2VClassesDictionarySerializer` is 'wordcluster', which is the key used to add the serializer to the map.

    Returns:
      A `Map` containing the added `serializers`.