Is your eventStream just empty? In this case the training code throws a NPE,
there is a jira issue for this. So you need at least some training data
to train a model.
I am not sure what the best response would be from our training code
when you train
with no events at all, anyway there should be a nicer way to communicate
back to the user
that it is not possible.
We don't really have any documentation about the machine learning APIs,
but you can
find many examples in our opennlp.tools source code, just look for
classes which end with
ME, e.g. DocumentCategorizerME is very simple and a good starting point.
Jörn
On 9/15/11 3:26 PM, Aditya Kulkarni wrote:
Hello Everyone,
Piece of code:
SimpleEventStream eventStream = new SimpleEventStream();
this.addEvents( "male", male, eventStream.getEvents() );
this.addEvents( "female", female, eventStream.getEvents() );
try {
return GIS.trainModel( (EventStream)eventStream, true);
//return GIS.trainModel( eventStream, 10, 0 );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Error:
GIS.trainModel fails with following error:
==========================================================
Indexing events using cutoff of 0
Computing event counts... Exception in thread "main"
java.lang.NullPointerException
at
opennlp.model.OnePassDataIndexer.computeEventCounts(OnePassDataIndexer.java:115)
at opennlp.model.OnePassDataIndexer.<init>(OnePassDataIndexer.java:76)
at opennlp.model.OnePassDataIndexer.<init>(OnePassDataIndexer.java:54)
at opennlp.maxent.GISTrainer.trainModel(GISTrainer.java:240)
at opennlp.maxent.GIS.trainModel(GIS.java:123)
at opennlp.maxent.GIS.trainModel(GIS.java:76)
at MaxentNameClassifier.train(MaxentNameClassifier.java:121)
at MaxentNameClassifier.demo(MaxentNameClassifier.java:90)
at MaxentNameClassifier.main(MaxentNameClassifier.java:62)
==========================================================
Please help! Also if there are any samples/tutorials for using this API,
that will be great pointer!
Thanks for your time.
-a