Package opennlp.tools.util.model
Class BaseModel
- java.lang.Object
-
- opennlp.tools.util.model.BaseModel
-
- All Implemented Interfaces:
java.io.Serializable,ArtifactProvider
- Direct Known Subclasses:
ChunkerModel,POSModel,TokenizerModel,TokenNameFinderModel
public abstract class BaseModel extends java.lang.Object implements ArtifactProvider, java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTRAINING_CUTOFF_PROPERTYstatic java.lang.StringTRAINING_EVENTHASH_PROPERTYstatic java.lang.StringTRAINING_ITERATIONS_PROPERTY
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetArtifact(java.lang.String key)Gets an artifact by namejava.lang.StringgetLanguage()Retrieves the language code of the material which was used to train the model or x-unspecified if non was set.java.lang.StringgetManifestProperty(java.lang.String key)Retrieves the value to the given key from the manifest.properties entry.VersiongetVersion()Retrieves the OpenNLP version which was used to create the model.booleanisLoadedFromSerialized()Indicates if this provider was loaded from serialized.voidserialize(java.io.File model)voidserialize(java.io.OutputStream out)Serializes the model to the givenOutputStream.voidserialize(java.nio.file.Path model)
-
-
-
Field Detail
-
TRAINING_CUTOFF_PROPERTY
public static final java.lang.String TRAINING_CUTOFF_PROPERTY
- See Also:
- Constant Field Values
-
TRAINING_ITERATIONS_PROPERTY
public static final java.lang.String TRAINING_ITERATIONS_PROPERTY
- See Also:
- Constant Field Values
-
TRAINING_EVENTHASH_PROPERTY
public static final java.lang.String TRAINING_EVENTHASH_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getManifestProperty
public final java.lang.String getManifestProperty(java.lang.String key)
Retrieves the value to the given key from the manifest.properties entry.- Specified by:
getManifestPropertyin interfaceArtifactProvider- Parameters:
key-- Returns:
- the value
-
getLanguage
public final java.lang.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:
getLanguagein interfaceArtifactProvider- 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(java.io.OutputStream out) throws java.io.IOExceptionSerializes the model to the givenOutputStream.- Parameters:
out- stream to write the model to- Throws:
java.io.IOException
-
serialize
public final void serialize(java.io.File model) throws java.io.IOException- Throws:
java.io.IOException
-
serialize
public final void serialize(java.nio.file.Path model) throws java.io.IOException- Throws:
java.io.IOException
-
getArtifact
public <T> T getArtifact(java.lang.String key)
Description copied from interface:ArtifactProviderGets an artifact by name- Specified by:
getArtifactin interfaceArtifactProvider
-
isLoadedFromSerialized
public boolean isLoadedFromSerialized()
Description copied from interface:ArtifactProviderIndicates 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:
isLoadedFromSerializedin interfaceArtifactProvider- Returns:
- true if this model was loaded from serialized
-
-