NaiveBayesModelReader (Apache OpenNLP Tools 2.5.9 API)
Description: declaration: package: opennlp.tools.ml.naivebayes, class: NaiveBayesModelReader

# 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 of `models`. 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 (`int` `int[]`)
[# of predicates for which outcome pattern is true] [outcome pattern]
4. # of predicates (`int`)
* list of predicate names (`String`)

See Also:
  - `NaiveBayesModel`
  - `AbstractModelReader`

- ## Field Summary

  ### Fields inherited from class AbstractModelReader

  `MAX_ENTRIES_PROPERTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NaiveBayesModelReader(File file)`
  Initializes a `NaiveBayesModelReader` via a `File`.
  `NaiveBayesModelReader(DataReader dataReader)`
  Initializes a `NaiveBayesModelReader` via a `DataReader`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkModelType()`
  Reads the mode type from the underlying reader and informs if it not a `Naive Bayes` model.
  `AbstractModel`
  `constructModel()`
  Constructs a `model`.

  ### Methods inherited from class AbstractModelReader

  `getModel, readDouble, readInt, readUTF`

  ### Methods inherited from class Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### NaiveBayesModelReader

    public NaiveBayesModelReader(File file) throws IOException
    Initializes a `NaiveBayesModelReader` via a `File`.
    Parameters:
      `file` - The `File` that references the model to be read.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### NaiveBayesModelReader

    public NaiveBayesModelReader(DataReader dataReader)
    Initializes a `NaiveBayesModelReader` via a `DataReader`.
    Parameters:
      `dataReader` - The `DataReader` that references the model to be read.

- ## Method Details

  - ### constructModel

    public AbstractModel constructModel() throws IOException
    Constructs a `model`.

    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 class `AbstractModelReader`
    Returns:
      A `NaiveBayesModel` 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 a `Naive Bayes` model.
    Specified by:
      `checkModelType` in class `AbstractModelReader`
    Throws:
      `IOException` - Thrown if IO errors occurred.