Menu

Sentence Detector 1.5.0 error message

Help
Anonymous
2010-10-07
2013-04-16
  • Anonymous

    Anonymous - 2010-10-07

    Hi there, this is my first time using opennlp.

    I need to use the sentence detector. Here is the code (mostly copy-paste from the example page):

    public String splitText (String text) throws FileNotFoundException {

    System.out.println("Loading sentence splitter model…");

    InputStream modelIn = new FileInputStream("models\\en-sent.bin");
    SentenceModel model = null;

    try {
      model = new SentenceModel(modelIn);
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    finally {
      if (modelIn != null) {
        try {
          modelIn.close();
        }
        catch (IOException e) {
        }
      }
    }
    System.out.println("Done.");

    SentenceDetectorME sentenceDetector = new SentenceDetectorME(model);
    return sentenceDetector.sentDetect(text);

    }

    I get this error:

    Loading sentence splitter model…
    Exception in thread "main" java.lang.NoClassDefFoundError: opennlp/model/MaxentModel
    at textpreproc.SentenceSplitter.splitText(SentenceSplitter.java:22)
    at main.Main.test(Main.java:43)
    at main.Main.main(Main.java:33)
    Caused by: java.lang.ClassNotFoundException: opennlp.model.MaxentModel
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

    I have imported opennlp.tools.sentdetect.* , i have the model in the /models directory (and it loads ok).

    What am i doing wrong?

    Thanks!

     
  • Joern Kottmann

    Joern Kottmann - 2010-10-07

    You are missing the maxent 3.0.0 jar file on your classpath. Its in the lib directory of the binary distribution.

    Hope that helps,
    Jörn

     
  • Anonymous

    Anonymous - 2010-10-08

    That was it, Thanks for the quick answer. I just assumed that the opennlp jar had everything it needed in itself.

    Stefan

     
  • charith soori

    charith soori - 2011-06-23

    Thanks for simple answer.

     

Log in to post a comment.