You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@opennlp.apache.org by Ryan Zeigler <ry...@hlt.utdallas.edu> on 2012/08/04 21:12:45 UTC
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?
RE: SuffixSensitiveGISModelWriter/Reader Issue
Posted by Jeyendran Balakrishnan <jp...@personaltube.com>.
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:ryan@hlt.utdallas.edu]
Sent: Saturday, August 04, 2012 12:13 PM
To: users@opennlp.apache.org
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?