Package opennlp.tools.ml.naivebayes

# Class BinaryNaiveBayesModelWriter

java.lang.Object
opennlp.tools.ml.model.AbstractModelWriter
opennlp.tools.ml.AbstractMLModelWriter
opennlp.tools.ml.naivebayes.NaiveBayesModelWriter
opennlp.tools.ml.naivebayes.BinaryNaiveBayesModelWriter

public class BinaryNaiveBayesModelWriter extends NaiveBayesModelWriter
A `NaiveBayesModelWriter` that writes models in a binary format.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BinaryNaiveBayesModelWriter(AbstractModel model, DataOutputStream dos)`
  Instantiates `BinaryNaiveBayesModelWriter` via an `naive bayes model` and a `DataOutputStream`.
  `BinaryNaiveBayesModelWriter(AbstractModel model, File f)`
  Instantiates `BinaryNaiveBayesModelWriter` via an `naive bayes model` and a `File`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the underlying `DataOutputStream`.
  `void`
  `writeDouble(double d)`
  Writes a single `double` to the underlying `DataOutputStream`.
  `void`
  `writeInt(int i)`
  Writes a single `int` to the underlying `DataOutputStream`.
  `void`
  `writeUTF(String s)`
  Writes a `String` to the underlying `DataOutputStream`.

  ### Methods inherited from class opennlp.tools.ml.naivebayes.NaiveBayesModelWriter

  `persist`

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### BinaryNaiveBayesModelWriter

    public BinaryNaiveBayesModelWriter(AbstractModel model, File f) throws IOException
    Instantiates `BinaryNaiveBayesModelWriter` via an `naive bayes model` and a `File`. Prepares writing of a `model` to the file. Based on whether the file's suffix contains `.gz`, it detects whether the file is gzipped or not.
    Parameters:
      `model` - The `naive bayes model` which is to be persisted.
      `f` - The `File` in which the model is to be persisted.
    Throws:
      `IOException` - Thrown if IO errors occurred.
    See Also:
      - `NaiveBayesModel`

  - ### BinaryNaiveBayesModelWriter

    public BinaryNaiveBayesModelWriter(AbstractModel model, DataOutputStream dos)
    Instantiates `BinaryNaiveBayesModelWriter` via an `naive bayes model` and a `DataOutputStream`.
    Parameters:
      `model` - The `naive bayes model` which is to be persisted.
      `dos` - The `DataOutputStream` which is used to persist the `model`. The `dos` must be opened.

- ## Method Details

  - ### writeUTF

    public void writeUTF(String s) throws IOException
    Description copied from class: `AbstractModelWriter`
    Writes a `String` to the underlying `DataOutputStream`.
    Specified by:
      `writeUTF` in class `AbstractModelWriter`
    Parameters:
      `s` - The `UTF encoded` characters.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### writeInt

    public void writeInt(int i) throws IOException
    Description copied from class: `AbstractModelWriter`
    Writes a single `int` to the underlying `DataOutputStream`.
    Specified by:
      `writeInt` in class `AbstractModelWriter`
    Parameters:
      `i` - The `int` value.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### writeDouble

    public void writeDouble(double d) throws IOException
    Description copied from class: `AbstractModelWriter`
    Writes a single `double` to the underlying `DataOutputStream`.
    Specified by:
      `writeDouble` in class `AbstractModelWriter`
    Parameters:
      `d` - The `double` value.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### close

    public void close() throws IOException
    Description copied from class: `AbstractModelWriter`
    Closes the underlying `DataOutputStream`.
    Specified by:
      `close` in class `AbstractModelWriter`
    Throws:
      `IOException` - Thrown if IO errors occurred.