POSTaggerFactory (Apache OpenNLP :: Core :: Runtime 3.0.0-M4 API)
Description: declaration: package: opennlp.tools.postag, class: POSTaggerFactory

Package opennlp.tools.postag

# Class POSTaggerFactory

java.lang.Object
opennlp.tools.util.BaseToolFactory
opennlp.tools.postag.POSTaggerFactory

public class POSTaggerFactory extends BaseToolFactory
The factory that provides `POSTagger` default implementations and resources.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `POSTaggerFactory.POSDictionarySerializer`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `POSTaggerFactory()`
  Initializes a `POSTaggerFactory` that provides the default implementation of the resources.
  `POSTaggerFactory(byte[] featureGeneratorBytes, Map<String,Object> resources, opennlp.tools.postag.TagDictionary posDictionary)`
  Initializes a `POSTaggerFactory` from a given set of the resources.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static POSTaggerFactory`
  `create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, opennlp.tools.postag.TagDictionary posDictionary)`
  Instantiates a `POSTaggerFactory` via a given `subclassName`.
  `Map<String,Object>`
  `createArtifactMap()`
  A model's implementation should call this constructor that creates a model programmatically.
  `Map<String,opennlp.tools.util.model.ArtifactSerializer<?>>`
  `createArtifactSerializersMap()`
  Creates a `Map` with pairs of keys and `ArtifactSerializer`.
  `opennlp.tools.postag.TagDictionary`
  `createEmptyTagDictionary()`
  `opennlp.tools.util.featuregen.AdaptiveFeatureGenerator`
  `createFeatureGenerators()`
  Creates the `AdaptiveFeatureGenerator`.
  `opennlp.tools.postag.TagDictionary`
  `createTagDictionary(File dictionary)`
  Initializes a `TagDictionary` from a `dictionary file`.
  `opennlp.tools.postag.TagDictionary`
  `createTagDictionary(InputStream in)`
  Initializes a `TagDictionary` from a `dictionary stream`.
  `opennlp.tools.postag.POSContextGenerator`
  `getPOSContextGenerator()`
  `opennlp.tools.postag.POSContextGenerator`
  `getPOSContextGenerator(int cacheSize)`
  `opennlp.tools.util.SequenceValidator<String>`
  `getSequenceValidator()`
  `opennlp.tools.postag.TagDictionary`
  `getTagDictionary()`
  `void`
  `setTagDictionary(opennlp.tools.postag.TagDictionary dictionary)`
  `void`
  `validateArtifactMap()`
  Validates the parsed artifacts.

  ### Methods inherited from class opennlp.tools.util.BaseToolFactory

  `create, create, createManifestEntries`

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

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

- ## Constructor Details

  - ### POSTaggerFactory

    public POSTaggerFactory()
    Initializes a `POSTaggerFactory` that provides the default implementation of the resources.

  - ### POSTaggerFactory

    public POSTaggerFactory(byte[] featureGeneratorBytes, Map<String,Object> resources, opennlp.tools.postag.TagDictionary posDictionary)
    Initializes a `POSTaggerFactory` from a given set of the resources.
    Parameters:
      `featureGeneratorBytes` - The bytes for feature generation.
      `resources` - Additional resources as key-value map.
      `posDictionary` - A `TagDictionary` used for the new instance.

- ## Method Details

  - ### createFeatureGenerators

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

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

    Returns:
      the feature generator or `null` if there is no descriptor in the model
    Throws:
      `IllegalStateException` - Thrown if inconsistencies occurred during creation.

  - ### createArtifactSerializersMap

    public Map<String,opennlp.tools.util.model.ArtifactSerializer<?>> createArtifactSerializersMap()
    Description copied from class: `BaseToolFactory`
    Creates a `Map` with pairs of keys and `ArtifactSerializer`. The models implementation should call this method from `BaseModel#createArtifactSerializersMap`.

    The base implementation will return a `HashMap` that should be populated by subclasses.

    Overrides:
      `createArtifactSerializersMap` in class `BaseToolFactory`

  - ### createArtifactMap

    public Map<String,Object> createArtifactMap()
    Description copied from class: `BaseToolFactory`
    A model's implementation should call this constructor that creates a model programmatically.

    The base implementation will return a `HashMap` that should be populated by subclasses.

    Overrides:
      `createArtifactMap` in class `BaseToolFactory`
    Returns:
      Retrieves a `Map` with pairs of keys and objects.

  - ### createTagDictionary

    public opennlp.tools.postag.TagDictionary createTagDictionary(File dictionary) throws IOException
    Initializes a `TagDictionary` from a `dictionary file`.
    Parameters:
      `dictionary` - The `File` used for creating the dictionary.
    Returns:
      A valid `TagDictionary` ready for use.
    Throws:
      `IOException` - Thrown if IO errors occurred during creation.

  - ### createTagDictionary

    public opennlp.tools.postag.TagDictionary createTagDictionary(InputStream in) throws IOException
    Initializes a `TagDictionary` from a `dictionary stream`.
    Parameters:
      `in` - The `InputStream` used for creating the dictionary.
    Returns:
      A valid `TagDictionary` ready for use.
    Throws:
      `IOException` - Thrown if IO errors occurred during creation.

  - ### setTagDictionary

    public void setTagDictionary(opennlp.tools.postag.TagDictionary dictionary)

  - ### getTagDictionary

    public opennlp.tools.postag.TagDictionary getTagDictionary()
    Returns:
      The `TagDictionary` used.

  - ### getPOSContextGenerator

    public opennlp.tools.postag.POSContextGenerator getPOSContextGenerator()
    Returns:
      The `POSContextGenerator` with a default cache size of `0`.

  - ### getPOSContextGenerator

    public opennlp.tools.postag.POSContextGenerator getPOSContextGenerator(int cacheSize)
    Parameters:
      `cacheSize` - Must be greater than or equal to `0`.
    Returns:
      The `POSContextGenerator` configured with the given `cacheSize`.

  - ### getSequenceValidator

    public opennlp.tools.util.SequenceValidator<String> getSequenceValidator()
    Returns:
      The `SequenceValidator` used.

  - ### validateArtifactMap

    public void validateArtifactMap() throws opennlp.tools.util.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:
      `opennlp.tools.util.InvalidFormatException` - Thrown if validation found invalid states.

  - ### create

    public static POSTaggerFactory create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, opennlp.tools.postag.TagDictionary posDictionary) throws opennlp.tools.util.InvalidFormatException
    Instantiates a `POSTaggerFactory` via a given `subclassName`.
    Parameters:
      `subclassName` - The class name used for instantiation. If `null`, an instance of `POSTaggerFactory` will be returned per default. Otherwise, the `ExtensionLoader` mechanism is applied to load the requested `subclassName`.
      `featureGeneratorBytes` - The bytes for feature generation.
      `resources` - Additional resources as key-value map.
      `posDictionary` - A `TagDictionary` used for the new instance.
    Returns:
      @return A valid `POSTaggerFactory` instance.
    Throws:
      `opennlp.tools.util.InvalidFormatException` - Thrown if the `ExtensionLoader` mechanism failed to load the factory via the `subclassName`.

  - ### createEmptyTagDictionary

    public opennlp.tools.postag.TagDictionary createEmptyTagDictionary()
    Returns:
      An empty, case-sensitive `TagDictionary`.