Package opennlp.tools.ml.model
Class AbstractModelReader
- java.lang.Object
-
- opennlp.tools.ml.model.AbstractModelReader
-
- Direct Known Subclasses:
GenericModelReader,GISModelReader,NaiveBayesModelReader,PerceptronModelReader
public abstract class AbstractModelReader extends Object
An abstract, basic implementation of a model reader.
-
-
Constructor Summary
Constructors Constructor Description AbstractModelReader(File f)Initializes aAbstractModelReadervia aFile.AbstractModelReader(DataReader dataReader)Initializes aAbstractModelReadervia aDataReader.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidcheckModelType()Checks the model type via the the underlyingDataReader.abstract AbstractModelconstructModel()Constructs amodel.AbstractModelgetModel()doublereadDouble()Implement as needed for the format the model is stored in.intreadInt()Implement as needed for the format the model is stored in.StringreadUTF()Implement as needed for the format the model is stored in.
-
-
-
Constructor Detail
-
AbstractModelReader
public AbstractModelReader(File f) throws IOException
Initializes aAbstractModelReadervia aFile.- Parameters:
f- TheFilethat references the model to be read.- Throws:
IOException- Thrown if IO errors occurred.
-
AbstractModelReader
public AbstractModelReader(DataReader dataReader)
Initializes aAbstractModelReadervia aDataReader.- Parameters:
dataReader- TheDataReaderthat references the model to be read.
-
-
Method Detail
-
readInt
public int readInt() throws IOExceptionImplement as needed for the format the model is stored in.- Returns:
- Reads in an
intvalue from the underlyingDataReader. - Throws:
IOException
-
readDouble
public double readDouble() throws IOExceptionImplement as needed for the format the model is stored in.- Returns:
- Reads in a
doublevalue from the underlyingDataReader. - Throws:
IOException
-
readUTF
public String readUTF() throws IOException
Implement as needed for the format the model is stored in.- Returns:
- Reads in an
UTF-encoded Stringvalue from the underlyingDataReader. - Throws:
IOException
-
getModel
public AbstractModel getModel() throws IOException
- Returns:
- Retrieves the read
AbstractModelinstance. - Throws:
IOException- Thrown if IO errors occurred constructing the model.
-
checkModelType
public abstract void checkModelType() throws IOExceptionChecks the model type via the the underlyingDataReader.- Throws:
IOException- Thrown if IO errors occurred checking the model type.
-
constructModel
public abstract AbstractModel constructModel() throws IOException
Constructs amodel.- Returns:
- A
AbstractModelreconstructed from a model's (read) attributes. - Throws:
IOException- Thrown if IO errors occurred during (re-)construction.
-
-