opennlp.tools.util.model
Class BaseModel

java.lang.Object
  extended by opennlp.tools.util.model.BaseModel
Direct Known Subclasses:
ChunkerModel, CorefModel, DoccatModel, ParserModel, POSModel, SentenceModel, TokenizerModel, TokenNameFinderModel

public abstract class BaseModel
extends Object

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


Field Summary
protected  Map<String,Object> artifactMap
           
protected static String MANIFEST_ENTRY
           
static String TRAINING_CUTOFF_PROPERTY
           
static String TRAINING_EVENTHASH_PROPERTY
           
static String TRAINING_ITERATIONS_PROPERTY
           
 
Constructor Summary
protected BaseModel(String componentName, InputStream in)
          Initializes the current instance.
protected BaseModel(String componentName, String languageCode, Map<String,String> manifestInfoEntries)
          Initializes the current instance.
 
Method Summary
protected  void createArtifactSerializers(Map<String,ArtifactSerializer> serializers)
          Registers all ArtifactSerializer for their artifact file name extensions.
protected  ArtifactSerializer getArtifactSerializer(String resoruceName)
           
 String getLanguage()
          Retrieves the language code of the material which was used to train the model or x-unspecified if non was set.
 String getManifestProperty(String key)
          Retrieves the value to the given key from the manifest.properties entry.
 Version getVersion()
          Retrieves the OpenNLP version which was used to create the model.
 void serialize(OutputStream out)
          Serializes the model to the given OutputStream.
protected  void setManifestProperty(String key, String value)
          Sets a given value for a given key to the manifest.properties entry.
protected  void validateArtifactMap()
          Validates the parsed artifacts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_ENTRY

protected static final String MANIFEST_ENTRY
See Also:
Constant Field Values

TRAINING_CUTOFF_PROPERTY

public static final String TRAINING_CUTOFF_PROPERTY
See Also:
Constant Field Values

TRAINING_ITERATIONS_PROPERTY

public static final String TRAINING_ITERATIONS_PROPERTY
See Also:
Constant Field Values

TRAINING_EVENTHASH_PROPERTY

public static final String TRAINING_EVENTHASH_PROPERTY
See Also:
Constant Field Values

artifactMap

protected final Map<String,Object> artifactMap
Constructor Detail

BaseModel

protected BaseModel(String componentName,
                    String languageCode,
                    Map<String,String> manifestInfoEntries)
Initializes the current instance.

Parameters:
languageCode -
manifestInfoEntries - additional information in the manifest

BaseModel

protected BaseModel(String componentName,
                    InputStream in)
             throws IOException,
                    InvalidFormatException
Initializes the current instance.

Parameters:
in -
Throws:
IOException
InvalidFormatException
Method Detail

getArtifactSerializer

protected ArtifactSerializer getArtifactSerializer(String resoruceName)

createArtifactSerializers

protected void createArtifactSerializers(Map<String,ArtifactSerializer> serializers)
Registers all ArtifactSerializer for their artifact file name extensions. The registered ArtifactSerializer are used to create and serialize resources in the model package. Override this method to register custom ArtifactSerializers. Note: Subclasses should generally invoke super.createArtifactSerializers at the beginning of this method. This method is called during construction.

Parameters:
serializers - the key of the map is the file extension used to lookup the ArtifactSerializer.

validateArtifactMap

protected void validateArtifactMap()
                            throws InvalidFormatException
Validates the parsed artifacts. If something is not valid subclasses should throw an InvalidFormatException. Note: Subclasses should generally invoke super.validateArtifactMap at the beginning of this method.

Throws:
InvalidFormatException

getManifestProperty

public final String getManifestProperty(String key)
Retrieves the value to the given key from the manifest.properties entry.

Parameters:
key -
Returns:

setManifestProperty

protected final void setManifestProperty(String key,
                                         String value)
Sets a given value for a given key to the manifest.properties entry.

Parameters:
key -
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.

Returns:
the language code of this model

getVersion

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

Returns:

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


Copyright © 2010. All Rights Reserved.