Class BaseModel

java.lang.Object
opennlp.tools.util.model.BaseModel
All Implemented Interfaces:
Serializable, ArtifactProvider
Direct Known Subclasses:
ChunkerModel, POSModel, TokenizerModel, TokenNameFinderModel

public abstract class BaseModel extends Object implements ArtifactProvider, Serializable
This model is a common based which can be used by the components model classes. TODO: Provide sub classes access to serializers already in constructor
See Also:
  • Field Details

  • Method Details

    • getManifestProperty

      public final String getManifestProperty(String key)
      Retrieves the value to the given key from the manifest.properties entry.
      Specified by:
      getManifestProperty in interface ArtifactProvider
      Parameters:
      key -
      Returns:
      the value
    • getLanguage

      public final String getLanguage()
      Retrieves the language code of the material which was used to train the model or x-unspecified if non was set.
      Specified by:
      getLanguage in interface ArtifactProvider
      Returns:
      the language code of this model
    • getVersion

      public final Version getVersion()
      Retrieves the OpenNLP version which was used to create the model.
      Returns:
      the version
    • serialize

      public final void serialize(OutputStream out) throws IOException
      Serializes the model to the given OutputStream.
      Parameters:
      out - stream to write the model to
      Throws:
      IOException
    • serialize

      public final void serialize(File model) throws IOException
      Throws:
      IOException
    • serialize

      public final void serialize(Path model) throws IOException
      Throws:
      IOException
    • getArtifact

      public <T> T getArtifact(String key)
      Description copied from interface: ArtifactProvider
      Gets an artifact by name
      Specified by:
      getArtifact in interface ArtifactProvider
    • isLoadedFromSerialized

      public boolean isLoadedFromSerialized()
      Description copied from interface: ArtifactProvider
      Indicates if this provider was loaded from serialized. It is useful, for example, while validating artifacts: you can skip the time consuming ones if they where already validated during the serialization.
      Specified by:
      isLoadedFromSerialized in interface ArtifactProvider
      Returns:
      true if this model was loaded from serialized