You get FileNotFoundException, So the problem is you have not given the
path correctly.

try this: InputStream modelIn = new FileInputStream("Models/en-sent.bin");

Note: Check the case(Upper/Lower) of the letters too.


On Tue, Apr 22, 2014 at 2:24 PM, dhanashree thakur <[email protected]>wrote:

> thank you very much for helping me.
> I have downloaded 'en-sent.bin' models for Sentence detector.When I extract
> it,two files are created that are manifest.properties and sent.model. and i
> copied that files in Models folder. But When I run code in eclipse as:
> InputStream modelIn = new FileInputStream("Models\\en-sent.bin");
>
>         try {
>           SentenceModel model = new SentenceModel(modelIn);
>           SentenceDetectorME sentenceDetector = new
> SentenceDetectorME(model);
>             String sentences[] = sentenceDetector.sentDetect("  First
> sentence. Second sentence. ");
>         }
>         catch (IOException e) {
>           e.printStackTrace();
>         }
>         finally {
>           if (modelIn != null) {
>             try {
>               modelIn.close();
>             }
>             catch (IOException e) {
>             }
>
> It gives error as,
> Exception in thread "main" java.io.FileNotFoundException:
> Models\en-sent.bin (The system cannot find the file specified)
>     at java.io.FileInputStream.open(Native Method)
>     at java.io.FileInputStream.<init>(FileInputStream.java:106)
>     at java.io.FileInputStream.<init>(FileInputStream.java:66)
>     at SentenceSplit1.main(SentenceSplit1.java:14)
>
> What will be the problem?
>
>
>
> On Sun, Apr 20, 2014 at 8:48 AM, Tech mail <[email protected]> wrote:
>
> > You have some basic choices
> > 1. If you're using maven for your project then Just add the dependency
> > tags for opennlp to your Pom
> > 2. If not using maven download the jars and add it to your class path of
> > your project you want to use it in
> > 3. Download the latest source code and build with maven then do 1 or 2
> > above with the 1.6 snapshot build
> >
> > Make sure you are using java 1.7 or prior, I'm not sure we compile with
> > 1.8 yet.
> >
> > Once you do one of the above, then use the Java API. You can also try the
> > CLI if you're trying to get a feel for it.
> >
> >
> >
> > > On Apr 20, 2014, at 6:28 AM, dhanashree thakur <[email protected]>
> > wrote:
> > >
> > > How to run opennlp using eclipse
> > >
> > > Thank you..
> > >
> > >> On 4/20/14, dhanashree thakur <[email protected]> wrote:
> > >> When I type bin/opennlp.bat  command ,it gives error as
> > >> Invalid maximum heap size:Xmx4096
> > >> The specified size exceeds the maximum representable size.
> > >> Could not create java virtual machine
> > >>
> > >>> On 4/16/14, William Colen <[email protected]> wrote:
> > >>> If you are using the binary distribution, execute the command from
> the
> > >>> first directory, outside of the bin folder.
> > >>>
> > >>> bin/opennlp.bat
> > >>>
> > >>> Em quarta-feira, 16 de abril de 2014, William Colen
> > >>> <[email protected]>
> > >>> escreveu:
> > >>>
> > >>>> Try to execute from opennlp-tools folder. The command would be
> > >>>>
> > >>>> bin/opennlp.bat
> > >>>>
> > >>>> Em quarta-feira, 16 de abril de 2014, dhanashree thakur <
> > >>>> [email protected]<javascript:_e(%7B%7D,'cvml','
> > [email protected]');>>
> > >>>> escreveu:
> > >>>>
> > >>>>> when I open opennlp.bat file,it closes itself immediately.and when
> i
> > >>>>> write
> > >>>>> command in cmd promt, set -Xmx4096m  to -Xmx1024m ,it give error
> that
> > >>>>> environmental variable for -Xmx4096m  to -Xmx1024m is not defined.
> > >>>>> How to set environmental variable for setting this.
> > >>>>>
> > >>>>>
> > >>>>> On Wed, Apr 16, 2014 at 1:29 AM, swapnil marathe <
> > [email protected]
> > >>>>>> wrote:
> > >>>>>
> > >>>>>> On Wed, Apr 16, 2014 at 1:42 PM, dhanashree thakur <
> > >>>>> [email protected]
> > >>>>>>> wrote:
> > >>>>>>
> > >>>>>>> Invalid maximum heap size: -Xmx4096m
> > >>>>>>
> > >>>>>>
> > >>>>>> this is your problem
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>>> open opennlp.bat file edit it :
> > >>>>>>
> > >>>>>> if you have 2gb of ram on your pc you can set
> > >>>>>> -Xmx4096m  to -Xmx1024m  or -Xmx512m
> > >>>>>>
> > >>>>>> so set it according to ram present on your system
> > >>>>
> > >>>>
> > >>>> --
> > >>>> William Colen
> > >>>
> > >>>
> > >>> --
> > >>> William Colen
> > >>
> >
>



-- 
Regards,
SASIKUMAR N

Reply via email to