You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@opennlp.apache.org by Aditya Kulkarni <ad...@gmail.com> on 2011/09/15 15:26:01 UTC

Error in GIS.trainModel

Hello Everyone,

Piece of code:

SimpleEventStream eventStream = new SimpleEventStream();
                this.addEvents(   "male",   male, eventStream.getEvents() );
                this.addEvents( "female", female, eventStream.getEvents() );
                try {
                    return GIS.trainModel( (EventStream)eventStream, true);
                    //return GIS.trainModel( eventStream, 10, 0 );
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

Error:
GIS.trainModel fails with following error:
==========================================================
Indexing events using cutoff of 0

    Computing event counts...  Exception in thread "main"
java.lang.NullPointerException
    at
opennlp.model.OnePassDataIndexer.computeEventCounts(OnePassDataIndexer.java:115)
    at opennlp.model.OnePassDataIndexer.<init>(OnePassDataIndexer.java:76)
    at opennlp.model.OnePassDataIndexer.<init>(OnePassDataIndexer.java:54)
    at opennlp.maxent.GISTrainer.trainModel(GISTrainer.java:240)
    at opennlp.maxent.GIS.trainModel(GIS.java:123)
    at opennlp.maxent.GIS.trainModel(GIS.java:76)
    at MaxentNameClassifier.train(MaxentNameClassifier.java:121)
    at MaxentNameClassifier.demo(MaxentNameClassifier.java:90)
    at MaxentNameClassifier.main(MaxentNameClassifier.java:62)
==========================================================

Please help! Also if there are any samples/tutorials for using this API,
that will be great pointer!

Thanks for your time.
-a

Re: Error in GIS.trainModel

Posted by Jörn Kottmann <ko...@gmail.com>.
On 9/16/11 8:07 PM, Aditya Kulkarni wrote:
> I checked again, but eventStream (object of SimpleEventStrem) is not null.
> Will sending of code will help?

Yes, but I suspect it does not return any events, and the stream is "empty".

Jörn

Re: Error in GIS.trainModel

Posted by Aditya Kulkarni <ad...@gmail.com>.
Hi Jörn,

I checked again, but eventStream (object of SimpleEventStrem) is not null.
Will sending of code will help?

Best regards,
Aditya
 On Thu, Sep 15, 2011 at 8:09 PM, Aditya Kulkarni <aditya.kulkarni@gmail.com
> wrote:

> Hi Jörn,
>
> Thanks for quick response. Let me go through it again and revert back with
> finding.
>
> Best Regards,
> Aditya
>
>
> On Thu, Sep 15, 2011 at 7:07 PM, Jörn Kottmann <ko...@gmail.com> wrote:
>
>> Is your eventStream just empty? In this case the training code throws a
>> NPE,
>> there is a jira issue for this. So you need at least some training data to
>> train a model.
>>
>> I am not sure what the best response would be from our training code when
>> you train
>> with no events at all, anyway there should be a nicer way to communicate
>> back to the user
>> that it is not possible.
>>
>> We don't really have any documentation about the machine learning APIs,
>> but you can
>> find many examples in our opennlp.tools source code, just look for classes
>> which end with
>> ME, e.g. DocumentCategorizerME is very simple and a good starting point.
>>
>> Jörn
>>
>>
>>
>> On 9/15/11 3:26 PM, Aditya Kulkarni wrote:
>>
>>> Hello Everyone,
>>>
>>> Piece of code:
>>>
>>> SimpleEventStream eventStream = new SimpleEventStream();
>>>                 this.addEvents(   "male",   male, eventStream.getEvents()
>>> );
>>>                 this.addEvents( "female", female, eventStream.getEvents()
>>> );
>>>                 try {
>>>                     return GIS.trainModel( (EventStream)eventStream,
>>> true);
>>>                     //return GIS.trainModel( eventStream, 10, 0 );
>>>                 } catch (IOException e) {
>>>                     // TODO Auto-generated catch block
>>>                     e.printStackTrace();
>>>                 }
>>>
>>> Error:
>>> GIS.trainModel fails with following error:
>>> ==============================**============================
>>> Indexing events using cutoff of 0
>>>
>>>     Computing event counts...  Exception in thread "main"
>>> java.lang.NullPointerException
>>>     at
>>> opennlp.model.**OnePassDataIndexer.**computeEventCounts(**
>>> OnePassDataIndexer.java:115)
>>>     at opennlp.model.**OnePassDataIndexer.<init>(**
>>> OnePassDataIndexer.java:76)
>>>     at opennlp.model.**OnePassDataIndexer.<init>(**
>>> OnePassDataIndexer.java:54)
>>>     at opennlp.maxent.GISTrainer.**trainModel(GISTrainer.java:**240)
>>>     at opennlp.maxent.GIS.trainModel(**GIS.java:123)
>>>     at opennlp.maxent.GIS.trainModel(**GIS.java:76)
>>>     at MaxentNameClassifier.train(**MaxentNameClassifier.java:121)
>>>     at MaxentNameClassifier.demo(**MaxentNameClassifier.java:90)
>>>     at MaxentNameClassifier.main(**MaxentNameClassifier.java:62)
>>> ==============================**============================
>>>
>>> Please help! Also if there are any samples/tutorials for using this API,
>>> that will be great pointer!
>>>
>>> Thanks for your time.
>>> -a
>>>
>>>
>>
>

Re: Error in GIS.trainModel

Posted by Aditya Kulkarni <ad...@gmail.com>.
Hi Jörn,

Thanks for quick response. Let me go through it again and revert back with
finding.

Best Regards,
Aditya

On Thu, Sep 15, 2011 at 7:07 PM, Jörn Kottmann <ko...@gmail.com> wrote:

> Is your eventStream just empty? In this case the training code throws a
> NPE,
> there is a jira issue for this. So you need at least some training data to
> train a model.
>
> I am not sure what the best response would be from our training code when
> you train
> with no events at all, anyway there should be a nicer way to communicate
> back to the user
> that it is not possible.
>
> We don't really have any documentation about the machine learning APIs, but
> you can
> find many examples in our opennlp.tools source code, just look for classes
> which end with
> ME, e.g. DocumentCategorizerME is very simple and a good starting point.
>
> Jörn
>
>
>
> On 9/15/11 3:26 PM, Aditya Kulkarni wrote:
>
>> Hello Everyone,
>>
>> Piece of code:
>>
>> SimpleEventStream eventStream = new SimpleEventStream();
>>                 this.addEvents(   "male",   male, eventStream.getEvents()
>> );
>>                 this.addEvents( "female", female, eventStream.getEvents()
>> );
>>                 try {
>>                     return GIS.trainModel( (EventStream)eventStream,
>> true);
>>                     //return GIS.trainModel( eventStream, 10, 0 );
>>                 } catch (IOException e) {
>>                     // TODO Auto-generated catch block
>>                     e.printStackTrace();
>>                 }
>>
>> Error:
>> GIS.trainModel fails with following error:
>> ==============================**============================
>> Indexing events using cutoff of 0
>>
>>     Computing event counts...  Exception in thread "main"
>> java.lang.NullPointerException
>>     at
>> opennlp.model.**OnePassDataIndexer.**computeEventCounts(**
>> OnePassDataIndexer.java:115)
>>     at opennlp.model.**OnePassDataIndexer.<init>(**
>> OnePassDataIndexer.java:76)
>>     at opennlp.model.**OnePassDataIndexer.<init>(**
>> OnePassDataIndexer.java:54)
>>     at opennlp.maxent.GISTrainer.**trainModel(GISTrainer.java:**240)
>>     at opennlp.maxent.GIS.trainModel(**GIS.java:123)
>>     at opennlp.maxent.GIS.trainModel(**GIS.java:76)
>>     at MaxentNameClassifier.train(**MaxentNameClassifier.java:121)
>>     at MaxentNameClassifier.demo(**MaxentNameClassifier.java:90)
>>     at MaxentNameClassifier.main(**MaxentNameClassifier.java:62)
>> ==============================**============================
>>
>> Please help! Also if there are any samples/tutorials for using this API,
>> that will be great pointer!
>>
>> Thanks for your time.
>> -a
>>
>>
>

Re: Error in GIS.trainModel

Posted by Jörn Kottmann <ko...@gmail.com>.
Is your eventStream just empty? In this case the training code throws a NPE,
there is a jira issue for this. So you need at least some training data 
to train a model.

I am not sure what the best response would be from our training code 
when you train
with no events at all, anyway there should be a nicer way to communicate 
back to the user
that it is not possible.

We don't really have any documentation about the machine learning APIs, 
but you can
find many examples in our opennlp.tools source code, just look for 
classes which end with
ME, e.g. DocumentCategorizerME is very simple and a good starting point.

Jörn


On 9/15/11 3:26 PM, Aditya Kulkarni wrote:
> Hello Everyone,
>
> Piece of code:
>
> SimpleEventStream eventStream = new SimpleEventStream();
>                  this.addEvents(   "male",   male, eventStream.getEvents() );
>                  this.addEvents( "female", female, eventStream.getEvents() );
>                  try {
>                      return GIS.trainModel( (EventStream)eventStream, true);
>                      //return GIS.trainModel( eventStream, 10, 0 );
>                  } catch (IOException e) {
>                      // TODO Auto-generated catch block
>                      e.printStackTrace();
>                  }
>
> Error:
> GIS.trainModel fails with following error:
> ==========================================================
> Indexing events using cutoff of 0
>
>      Computing event counts...  Exception in thread "main"
> java.lang.NullPointerException
>      at
> opennlp.model.OnePassDataIndexer.computeEventCounts(OnePassDataIndexer.java:115)
>      at opennlp.model.OnePassDataIndexer.<init>(OnePassDataIndexer.java:76)
>      at opennlp.model.OnePassDataIndexer.<init>(OnePassDataIndexer.java:54)
>      at opennlp.maxent.GISTrainer.trainModel(GISTrainer.java:240)
>      at opennlp.maxent.GIS.trainModel(GIS.java:123)
>      at opennlp.maxent.GIS.trainModel(GIS.java:76)
>      at MaxentNameClassifier.train(MaxentNameClassifier.java:121)
>      at MaxentNameClassifier.demo(MaxentNameClassifier.java:90)
>      at MaxentNameClassifier.main(MaxentNameClassifier.java:62)
> ==========================================================
>
> Please help! Also if there are any samples/tutorials for using this API,
> that will be great pointer!
>
> Thanks for your time.
> -a
>