Example usage for opennlp.tools.util.model BaseModel serialize

List of usage examples for opennlp.tools.util.model BaseModel serialize

Introduction

In this page you can find the example usage for opennlp.tools.util.model BaseModel serialize.

Prototype

public final void serialize(Path model) throws IOException 

Source Link

Usage

From source file:es.ehu.si.ixa.pipe.nerc.train.InputOutputUtils.java

public static void saveModel(BaseModel trainedModel, String outfile) {
    OutputStream modelOut = null;
    try {/*from w  w w.  j a  va 2 s  .  co m*/
        modelOut = new BufferedOutputStream(new FileOutputStream(outfile));
        trainedModel.serialize(modelOut);
    } catch (IOException e) {
        // Failed to save model
        e.printStackTrace();
    } finally {
        if (modelOut != null) {
            try {
                modelOut.close();
            } catch (IOException e) {
                // Failed to correctly save model.
                // Written model might be invalid.
                e.printStackTrace();
            }
        }
    }
}