0

I have downloaded Apache opennlp from opennlp and after extracting added the two .jar files in the referenced libraries. write a simple code:

    modelIn = new FileInputStream("en-sent.bin");

OUTPUT:

java.io.FileNotFoundException: en-sent.bin (The system cannot find the file specified)
 at java.io.FileInputStream.open0(Native Method)
 at java.io.FileInputStream.open(Unknown Source)
 at java.io.FileInputStream.<init>(Unknown Source)
 at java.io.FileInputStream.<init>(Unknown Source)
 at Home.main(Home.java:16)
MWiesner
  • 8,868
  • 11
  • 36
  • 70
  • 1
    Please reformat to make it clear. Put your stacktrace in code block as well. Having bunch of /// wont help anyone. – Adarsha Sep 15 '15 at 05:06
  • possible duplicate of [Why does the loading of a POSModel file not work from inside the WEB-INF folder?](http://stackoverflow.com/questions/32148328/why-does-the-loading-of-a-posmodel-file-not-work-from-inside-the-web-inf-folder) – MWiesner Sep 16 '15 at 14:12

1 Answers1

0

I would suggest to use Maven for those dependencies.

For integrating the Sentence Detection API to your Java project, you will need to download the pre-trained model en-sent.bin from http://opennlp.sourceforge.net/models-1.5/ and add it to your classpath or point to its full path on your filesystem.

Then just follow Apache OpenNLP documentation:

InputStream modelIn = new FileInputStream("en-sent.bin");

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

I really recommand to read more on it here: http://blog.dpdearing.com/2011/05/opennlp-1-5-0-basics-sentence-detection-and-tokenizing/ and here: http://www.javaworld.com/article/2077352/java-se/smartly-load-your-properties.html

Shmulik Klein
  • 3,754
  • 19
  • 34