NullPointerException - crossValidator

Help
Anonymous
2012-03-09
2013-04-16
  • Anonymous - 2012-03-09

    Hi everyone,

    Can someone please explain why i 'm getting this very strange 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

    p.s: perhaps I should clarify that i 'm using the latest code from svn…

     
  • Anonymous - 2012-03-09

    Ooops! The forum is closed?

    Sorry my bad!!!

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks