Hi everyone,

Can someone please explain why i 'm getting this NPE when trying to use the TokenNameFinderCrossValidator? TokenNameFinderEvaluator seems to be working just fine but because i've got very little training-data i'd like to do cross-validation as well...

*The code is as follows:*

public String cross-validate(String fname, int kFolds){

FileInputStream sampleDataIn = new FileInputStream(fname);
ObjectStream<NameSample> sampleStream = new NameSampleDataStream(
new PlainTextByLineStream( sampleDataIn.getChannel(), "UTF-8")); TokenNameFinderCrossValidator judge = new TokenNameFinderCrossValidator("en", null, new TrainingParameters(), null, null, null);
 judge.evaluate(sampleStream, kFolds);
 FMeasure result = evaluator.getFMeasure();
 return result.toString();

}

*The exception is thrown right after the first 100 iterations for the first fold*:

NullPointerException opennlp.tools.namefind.TokenNameFinderModel.<init> (TokenNameFinderModel.java:90)

*If i omit the "new NameSampleDataStream()" (as shown in the docs) i get a different error saying:*

ClassCastException java.lang.String cannot be cast to opennlp.tools.namefind.NameSample opennlp.tools.namefind.TokenNameFinderCrossValidator$NameToDocumentSampleStream.read (TokenNameFinderCrossValidator.java:67)

What am i missing?

Thanks in advance...

Jim




Reply via email to