Package opennlp.tools.ml.naivebayes
Class NaiveBayesModelReader
- java.lang.Object
- 
- opennlp.tools.ml.model.AbstractModelReader
- 
- opennlp.tools.ml.naivebayes.NaiveBayesModelReader
 
 
- 
- Direct Known Subclasses:
- BinaryNaiveBayesModelReader,- PlainTextNaiveBayesModelReader
 
 public class NaiveBayesModelReader extends AbstractModelReader The base class for readers ofmodels. It assumes that models are saved in the following sequence:
 NaiveBayes (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 (intint[])
 [# of predicates for which outcome pattern is true] [outcome pattern]
 4. # of predicates (int)
 * list of predicate names (String)- See Also:
- NaiveBayesModel,- AbstractModelReader
 
- 
- 
Constructor SummaryConstructors Constructor Description NaiveBayesModelReader(File file)Initializes aNaiveBayesModelReadervia aFile.NaiveBayesModelReader(DataReader dataReader)Initializes aNaiveBayesModelReadervia aDataReader.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckModelType()Reads the mode type from the underlying reader and informs if it not aNaive Bayesmodel.AbstractModelconstructModel()Constructs amodel.- 
Methods inherited from class opennlp.tools.ml.model.AbstractModelReadergetModel, readDouble, readInt, readUTF
 
- 
 
- 
- 
- 
Constructor Detail- 
NaiveBayesModelReaderpublic NaiveBayesModelReader(File file) throws IOException Initializes aNaiveBayesModelReadervia aFile.- Parameters:
- file- The- Filethat references the model to be read.
- Throws:
- IOException- Thrown if IO errors occurred.
 
 - 
NaiveBayesModelReaderpublic NaiveBayesModelReader(DataReader dataReader) Initializes aNaiveBayesModelReadervia aDataReader.- Parameters:
- dataReader- The- DataReaderthat references the model to be read.
 
 
- 
 - 
Method Detail- 
constructModelpublic 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 xmlfile), override this method and ignore the other methods provided in this abstract class.- Specified by:
- constructModelin class- AbstractModelReader
- Returns:
- A NaiveBayesModelreconstructed from a model's (read) attributes.
- Throws:
- IOException- Thrown if IO errors occurred during (re-)construction.
 
 - 
checkModelTypepublic void checkModelType() throws IOExceptionReads the mode type from the underlying reader and informs if it not aNaive Bayesmodel.- Specified by:
- checkModelTypein class- AbstractModelReader
- Throws:
- IOException- Thrown if IO errors occurred.
 
 
- 
 
-