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!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!
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
That was it, Thanks for the quick answer. I just assumed that the opennlp jar had everything it needed in itself.
Stefan
Thanks for simple answer.