Class AbstractModelReader
java.lang.Object
opennlp.tools.ml.model.AbstractModelReader
- Direct Known Subclasses:
GenericModelReader
An abstract, basic implementation of a model reader.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUpper bound on count fields read from a model file.static final StringSystem property for overriding the maximum number of entries (outcomes, predicates, outcome patterns, chunk counts) that may be read from a model file or training data. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes aAbstractModelReadervia aFile.AbstractModelReader(opennlp.tools.ml.model.DataReader dataReader) Initializes aAbstractModelReadervia aDataReader. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidChecks the model type via the the underlyingDataReader.abstract AbstractModelConstructs amodel.getModel()doubleImplement as needed for the format the model is stored in.intreadInt()Implement as needed for the format the model is stored in.readUTF()Implement as needed for the format the model is stored in.
-
Field Details
-
MAX_ENTRIES_PROPERTY
System property for overriding the maximum number of entries (outcomes, predicates, outcome patterns, chunk counts) that may be read from a model file or training data. Alias ofResourceLimits.MAX_ENTRIES_PROPERTY.- See Also:
-
MAX_ENTRIES
public static final int MAX_ENTRIESUpper bound on count fields read from a model file. Alias ofResourceLimits.MAX_ENTRIES. Public so that deserializers outside this package which implement their own binary format can apply the same bound to their count fields.
-
-
Constructor Details
-
AbstractModelReader
Initializes aAbstractModelReadervia aFile.- Parameters:
f- TheFilethat references the model to be read.- Throws:
IOException- Thrown if IO errors occurred.
-
AbstractModelReader
public AbstractModelReader(opennlp.tools.ml.model.DataReader dataReader) Initializes aAbstractModelReadervia aDataReader.- Parameters:
dataReader- TheDataReaderthat references the model to be read.
-
-
Method Details
-
readInt
Implement as needed for the format the model is stored in.- Returns:
- Reads in an
intvalue from the underlyingDataReader. - Throws:
IOException
-
readDouble
Implement as needed for the format the model is stored in.- Returns:
- Reads in a
doublevalue from the underlyingDataReader. - Throws:
IOException
-
readUTF
Implement as needed for the format the model is stored in.- Returns:
- Reads in an
UTF-encoded Stringvalue from the underlyingDataReader. - Throws:
IOException
-
getModel
- Returns:
- Retrieves the read
AbstractModelinstance. - 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
AbstractModelreconstructed from a model's (read) attributes. - Throws:
IOException- Thrown if IO errors occurred during (re-)construction.
-