Package opennlp.tools.ml.model
Class AbstractModelReader
java.lang.Object
opennlp.tools.ml.model.AbstractModelReader
- Direct Known Subclasses:
GenericModelReader
,GISModelReader
,NaiveBayesModelReader
,PerceptronModelReader
An abstract, basic implementation of a model reader.
-
Constructor Summary
ConstructorDescriptionInitializes aAbstractModelReader
via aFile
.AbstractModelReader
(DataReader dataReader) Initializes aAbstractModelReader
via aDataReader
. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Checks the model type via the the underlyingDataReader
.abstract AbstractModel
Constructs amodel
.getModel()
double
Implement as needed for the format the model is stored in.int
readInt()
Implement as needed for the format the model is stored in.readUTF()
Implement as needed for the format the model is stored in.
-
Constructor Details
-
AbstractModelReader
Initializes aAbstractModelReader
via aFile
.- Parameters:
f
- TheFile
that references the model to be read.- Throws:
IOException
- Thrown if IO errors occurred.
-
AbstractModelReader
Initializes aAbstractModelReader
via aDataReader
.- Parameters:
dataReader
- TheDataReader
that references the model to be read.
-
-
Method Details
-
readInt
Implement as needed for the format the model is stored in.- Returns:
- Reads in an
int
value from the underlyingDataReader
. - Throws:
IOException
-
readDouble
Implement as needed for the format the model is stored in.- Returns:
- Reads in a
double
value from the underlyingDataReader
. - Throws:
IOException
-
readUTF
Implement as needed for the format the model is stored in.- Returns:
- Reads in an
UTF-encoded String
value from the underlyingDataReader
. - Throws:
IOException
-
getModel
- Returns:
- Retrieves the read
AbstractModel
instance. - Throws:
IOException
- Thrown if IO errors occurred constructing the model.
-
checkModelType
Checks the model type via the the underlyingDataReader
.- Throws:
IOException
- Thrown if IO errors occurred checking the model type.
-
constructModel
Constructs amodel
.- Returns:
- A
AbstractModel
reconstructed from a model's (read) attributes. - Throws:
IOException
- Thrown if IO errors occurred during (re-)construction.
-