Package opennlp.tools.ml.naivebayes
Class PlainTextNaiveBayesModelWriter
- java.lang.Object
-
- opennlp.tools.ml.model.AbstractModelWriter
-
- opennlp.tools.ml.naivebayes.NaiveBayesModelWriter
-
- opennlp.tools.ml.naivebayes.PlainTextNaiveBayesModelWriter
-
public class PlainTextNaiveBayesModelWriter extends NaiveBayesModelWriter
ANaiveBayesModelWriter
that writes models in a plain text format.
-
-
Constructor Summary
Constructors Constructor Description PlainTextNaiveBayesModelWriter(AbstractModel model, BufferedWriter bw)
PlainTextNaiveBayesModelWriter(AbstractModel model, File f)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the underlyingDataOutputStream
.void
writeDouble(double d)
Writes a singledouble
to the underlyingDataOutputStream
.void
writeInt(int i)
Writes a singleint
to the underlyingDataOutputStream
.void
writeUTF(String s)
Writes aString
to the underlyingDataOutputStream
.-
Methods inherited from class opennlp.tools.ml.naivebayes.NaiveBayesModelWriter
persist
-
-
-
-
Constructor Detail
-
PlainTextNaiveBayesModelWriter
public PlainTextNaiveBayesModelWriter(AbstractModel model, File f) throws IOException
InstantiatesPlainTextNaiveBayesModelWriter
via annaive bayes model
and aFile
. Prepares writing of amodel
to the file. Based on whether the file's suffix contains.gz
, it detects whether the file is gzipped or not.- Parameters:
model
- Thenaive bayes model
which is to be persisted.f
- TheFile
in which the model is to be persisted.- Throws:
IOException
- Thrown if IO errors occurred.- See Also:
NaiveBayesModel
-
PlainTextNaiveBayesModelWriter
public PlainTextNaiveBayesModelWriter(AbstractModel model, BufferedWriter bw)
InstantiatesPlainTextNaiveBayesModelWriter
via annaive bayes model
and aBufferedWriter
. Prepares writing amodel
to the file. Based on whether the file's suffix contains.gz
, it detects whether the file is gzipped or not.- Parameters:
model
- Thenaive bayes model
which is to be persisted.bw
- TheBufferedWriter
which is used to persist themodel
. Thebw
must be opened.
-
-
Method Detail
-
writeUTF
public void writeUTF(String s) throws IOException
Description copied from class:AbstractModelWriter
Writes aString
to the underlyingDataOutputStream
.- Specified by:
writeUTF
in classAbstractModelWriter
- Parameters:
s
- TheUTF encoded
characters.- Throws:
IOException
- Thrown if IO errors occurred.
-
writeInt
public void writeInt(int i) throws IOException
Description copied from class:AbstractModelWriter
Writes a singleint
to the underlyingDataOutputStream
.- Specified by:
writeInt
in classAbstractModelWriter
- Parameters:
i
- Theint
value.- Throws:
IOException
- Thrown if IO errors occurred.
-
writeDouble
public void writeDouble(double d) throws IOException
Description copied from class:AbstractModelWriter
Writes a singledouble
to the underlyingDataOutputStream
.- Specified by:
writeDouble
in classAbstractModelWriter
- Parameters:
d
- Thedouble
value.- Throws:
IOException
- Thrown if IO errors occurred.
-
close
public void close() throws IOException
Description copied from class:AbstractModelWriter
Closes the underlyingDataOutputStream
.- Specified by:
close
in classAbstractModelWriter
- Throws:
IOException
- Thrown if IO errors occurred.
-
-