Package opennlp.tools.postag

# Class POSModel

java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.postag.POSModel

All Implemented Interfaces:
  `Serializable`, `ArtifactProvider`, `SerializableArtifact`

public final class POSModel extends BaseModel implements SerializableArtifact
The `POSModel` is the model used by a learnable `POSTagger`.

See Also:
  - `POSTaggerME`
  - Serialized Form

- ## 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
  `POSModel(File modelFile)`
  Initializes a `POSModel` instance via a valid `File`.
  `POSModel(InputStream in)`
  Initializes a `POSModel` instance via a valid `InputStream`.
  `POSModel(String languageCode, MaxentModel posModel, int beamSize, Map<String,String> manifestInfoEntries, POSTaggerFactory posFactory)`
  Initializes a `POSModel` instance via given parameters.
  `POSModel(String languageCode, MaxentModel posModel, Map<String,String> manifestInfoEntries, POSTaggerFactory posFactory)`
  Initializes a `POSModel` instance via given parameters.
  `POSModel(String languageCode, SequenceClassificationModel<String> posModel, Map<String,String> manifestInfoEntries, POSTaggerFactory posFactory)`
  Initializes a `POSModel` instance via given parameters.
  `POSModel(URL modelURL)`
  Initializes a `POSModel` instance via a valid `URL`.
  `POSModel(Path modelPath)`
  Initializes a `POSModel` instance via a valid `Path`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `Class<POSModelSerializer>`
  `getArtifactSerializerClass()`
  Retrieves the class which can serialize and recreate this artifact.
  `POSTaggerFactory`
  `getFactory()`
  `MaxentModel`
  `getPosModel()`
  Deprecated.
  use `getPosSequenceModel()` instead.
  `SequenceClassificationModel<String>`
  `getPosSequenceModel()`
  `int`
  `hashCode()`

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

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

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

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

- ## Constructor Details

  - ### POSModel

    public POSModel(String languageCode, SequenceClassificationModel<String> posModel, Map<String,String> manifestInfoEntries, POSTaggerFactory posFactory)
    Initializes a `POSModel` instance via given parameters.
    Parameters:
      `languageCode` - An ISO conform language code.
      `posModel` - A valid `SequenceClassificationModel`.
      `manifestInfoEntries` - Additional information kept in the manifest.
      `posFactory` - The `POSTaggerFactory` for creating related objects.

  - ### POSModel

    public POSModel(String languageCode, MaxentModel posModel, Map<String,String> manifestInfoEntries, POSTaggerFactory posFactory)
    Initializes a `POSModel` instance via given parameters.
    Parameters:
      `languageCode` - An ISO conform language code.
      `posModel` - A valid `MaxentModel`.
      `manifestInfoEntries` - Additional information kept in the manifest.
      `posFactory` - The `POSTaggerFactory` for creating related objects.

  - ### POSModel

    public POSModel(String languageCode, MaxentModel posModel, int beamSize, Map<String,String> manifestInfoEntries, POSTaggerFactory posFactory)
    Initializes a `POSModel` instance via given parameters.
    Parameters:
      `languageCode` - An ISO conform language code.
      `posModel` - A valid `MaxentModel`.
      `beamSize` - The size of the beam that should be used when decoding sequences.
      `manifestInfoEntries` - Additional information kept in the manifest.
      `posFactory` - The `POSTaggerFactory` for creating related objects.

  - ### POSModel

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

  - ### POSModel

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

  - ### POSModel

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

  - ### POSModel

    public POSModel(URL modelURL) throws IOException
    Initializes a `POSModel` 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

  - ### getPosModel

    @Deprecated public MaxentModel getPosModel()
    Deprecated.
    use `getPosSequenceModel()` instead. This method will be removed soon. Only required for Parser 1.5.x backward compatibility. Newer models don't need this anymore.

  - ### getPosSequenceModel

    public SequenceClassificationModel<String> getPosSequenceModel()
    Returns:
      Retrieves a `SequenceClassificationModel`.

  - ### getFactory

    public POSTaggerFactory getFactory()
    Returns:
      Retrieves the active `POSTaggerFactory`.

  - ### getArtifactSerializerClass

    public Class<POSModelSerializer> getArtifactSerializerClass()
    Description copied from interface: `SerializableArtifact`
    Retrieves the class which can serialize and recreate this artifact.

    Note: The serializer class must have a `public zero argument constructor` or an exception is thrown during model serialization/loading.

    Specified by:
      `getArtifactSerializerClass` in interface `SerializableArtifact`
    Returns:
      The corresponding `ArtifactSerializer` class.

  - ### hashCode

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

  - ### equals

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