Package opennlp.tools.ml.model
Class GenericModelReader
java.lang.Object
opennlp.tools.ml.model.AbstractModelReader
opennlp.tools.ml.model.GenericModelReader
An generic
AbstractModelReader implementation.- See Also:
-
Field Summary
FieldsFields inherited from class opennlp.tools.ml.model.AbstractModelReader
dataReader, NUM_PREDS -
Constructor Summary
ConstructorsConstructorDescriptionInitializes aGenericModelReadervia aFile.GenericModelReader(DataReader dataReader) Initializes aGenericModelReadervia aDataReader. -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks the model type via the the underlyingDataReader.Constructs amodel.private AbstractModelReaderfromType(AlgorithmType type) Creates the delegate reader for the givenAlgorithmType.Methods inherited from class opennlp.tools.ml.model.AbstractModelReader
getModel, getOutcomePatterns, getOutcomes, getParameters, getPredicates, readDouble, readInt, readUTF
-
Field Details
-
delegateModelReader
-
-
Constructor Details
-
GenericModelReader
Initializes aGenericModelReadervia aFile.- Parameters:
f- TheFilethat references the model to be read.- Throws:
IOException- Thrown if IO errors occurred.
-
GenericModelReader
Initializes aGenericModelReadervia aDataReader.- Parameters:
dataReader- TheDataReaderthat references the model to be read.
-
-
Method Details
-
checkModelType
Description copied from class:AbstractModelReaderChecks the model type via the the underlyingDataReader.- Specified by:
checkModelTypein classAbstractModelReader- Throws:
IOException- Thrown if IO errors occurred checking the model type.
-
fromType
Creates the delegate reader for the givenAlgorithmType. The reader class is resolved viaExtensionLoader.loadExtensionClass(Class, String), so it has to reside in a package permitted by theExtensionLoader.- Parameters:
type- TheAlgorithmTypeto create a reader for.- Returns:
- The delegate
AbstractModelReader. - Throws:
ExtensionNotLoadedException- Thrown if the reader class is not in an allowed package or is not anAbstractModelReader.RuntimeException- Thrown if the reader class is not available or could not be instantiated.
-
constructModel
Description copied from class:AbstractModelReaderConstructs amodel.- Specified by:
constructModelin classAbstractModelReader- Returns:
- A
AbstractModelreconstructed from a model's (read) attributes. - Throws:
IOException- Thrown if IO errors occurred during (re-)construction.
-