This is what I've been using:

String modelFileName = ...;
File modelFile = new File(modelFileName);

Trainer:
GISModel model = GIS.trainModel(iterations, indexer, trace, useSmoothing,
null, cutoff, threadCount);
GISModelWriter writer = new SuffixSensitiveGISModelWriter(model,
outputModelFile);
writer.persist();
writer.close();

Classifier:
AbstractModel model = new
SuffixSensitiveGISModelReader(modelFile).getModel();

with appropriate try/catch logic inserted...

-jeyendran


-----Original Message-----
From: Ryan Zeigler [mailto:[email protected]] 
Sent: Saturday, August 04, 2012 12:13 PM
To: [email protected]
Subject: SuffixSensitiveGISModelWriter/Reader Issue

Hello,
I am having difficulty saving/loading GISModels using the opennlp maxent
package. I am attempting to save them with  the following code

OnePassDataIndexer indexer = new OnePassDataIndexer(evStream); GISModel
model = GIS.trainModel(this.iters, indexer); if (outputFile != null) {
        SuffixSensitiveGISModelWriter writer = 
                new SuffixSensitiveGISModelWriter(model, outputFile);
                writer.persist();
}

Subsequently, I am trying to load saved models with

SuffixSensitiveGISModelReader reader = 
                new SuffixSensitiveGISModelReader(file);
GISModel model = reader.constructModel();

If the output file is a text file. GISModelReader throws a number format
exception about the string GIS which is the first content in the .txt file.
If I delete this line the model loads and gives me expected performance.
When I use a bin or a bin.gz output file I receive an EOFException from
construct model. 

The same errors happen using PlainTextModelWriter. Am I using the API
incorrectly?

Reply via email to