Package opennlp.tools.ml.perceptron
Class PerceptronModelReader
- java.lang.Object
-
- opennlp.tools.ml.model.AbstractModelReader
-
- opennlp.tools.ml.perceptron.PerceptronModelReader
-
- Direct Known Subclasses:
BinaryPerceptronModelReader
public class PerceptronModelReader extends AbstractModelReader
The base class for readers ofmodels
. It assumes that models are saved in the following sequence:
Perceptron (model type identifier)
1. # of parameters (int
)
2. # of outcomes (int
)
* list of outcome names (String
)
3. # of different types of outcome patterns (int
)
* list of (int
int[]
)
[# of predicates for which outcome pattern is true] [outcome pattern]
4. # of predicates (int
)
* list of predicate names (String
)- See Also:
PerceptronModel
,AbstractModelReader
-
-
Constructor Summary
Constructors Constructor Description PerceptronModelReader(File file)
Initializes aPerceptronModelReader
via aFile
.PerceptronModelReader(DataReader dataReader)
Initializes aPerceptronModelReader
via aDataReader
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkModelType()
Reads the mode type from the underlying reader and informs if it not aPerceptron
model.AbstractModel
constructModel()
Constructs amodel
.-
Methods inherited from class opennlp.tools.ml.model.AbstractModelReader
getModel, readDouble, readInt, readUTF
-
-
-
-
Constructor Detail
-
PerceptronModelReader
public PerceptronModelReader(File file) throws IOException
Initializes aPerceptronModelReader
via aFile
.- Parameters:
file
- TheFile
that references the model to be read.- Throws:
IOException
- Thrown if IO errors occurred.
-
PerceptronModelReader
public PerceptronModelReader(DataReader dataReader)
Initializes aPerceptronModelReader
via aDataReader
.- Parameters:
dataReader
- TheDataReader
that references the model to be read.
-
-
Method Detail
-
constructModel
public AbstractModel constructModel() throws IOException
Constructs amodel
.If you are creating a reader for a format which won't work with this (perhaps a database or
xml
file), override this method and ignore the other methods provided in this abstract class.- Specified by:
constructModel
in classAbstractModelReader
- Returns:
- A
PerceptronModel
reconstructed from a model's (read) attributes. - Throws:
IOException
- Thrown if IO errors occurred during (re-)construction.
-
checkModelType
public void checkModelType() throws IOException
Reads the mode type from the underlying reader and informs if it not aPerceptron
model.- Specified by:
checkModelType
in classAbstractModelReader
- Throws:
IOException
- Thrown if IO errors occurred.
-
-