You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by "Manoj B. Narayanan" <ma...@gmail.com> on 2017/09/05 10:48:29 UTC

Re: Cache

Hi,

Could anyone please help me out.

Thanks,
Manoj

On Wed, Aug 30, 2017 at 10:47 AM, Manoj B. Narayanan <
manojb.narayanan2011@gmail.com> wrote:

> Hi,
>
> While training a NER model I use provide custom features by implementing *AdaptiveFeatureGenerator.
> *In the implementing class I compute certain features and add them. When
> I have another implementing class for adding features, I compute the
> features which sometimes are computed in the first implementing class
> itself. I am not aware of a mechanism where I can use the information from
> the first implementing class without computing them again.
>
> So, if there is a way where I could store some information about a
> sentence in a global manner, I would be able to get them in all the classes
> I need without computing them.
>
> If there is a provision for this already, please guide me. Else, I put
> forth this as a suggestion/request.
>
> Thanks,
> Manoj.
>
>
>

Re: Cache

Posted by "Manoj B. Narayanan" <ma...@gmail.com>.
Thanks Jörn and Daniel.  Will surely try them and revert.

Manoj.

On Wed, Sep 6, 2017 at 1:57 AM, Joern Kottmann <ko...@gmail.com> wrote:

> The feature generators are not thread safe, so it is ok to use an
> instance variable for caching.
> We have some feature generators which do that.
>
> Jörn
>
> On Tue, Sep 5, 2017 at 9:19 PM, Daniel Russ <dr...@apache.org> wrote:
> > Again, you should send this to users not dev mail list.
> >
> > Have you tried adding an instance variable  (e.g.  numWords) that you
> update when you call “createFeature”? You need to be concerned with thread
> safety if you do this on more than 1 thread, but you can synchronize only
> the part of the code that adds to the instance variable.  You should also
> be careful to create 1 instance of the AdaptiveFeatureGenerator.
> >
> > you might also consider resetting the value in the clearAdaptiveData
> method.  However, that might not work for you and you may need a method to
> reset your feature.
> >
> > Let me know if that works for you….
> >
> > Daniel
> >
> >> On Sep 5, 2017, at 6:48 AM, Manoj B. Narayanan <
> manojb.narayanan2011@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> Could anyone please help me out.
> >>
> >> Thanks,
> >> Manoj
> >>
> >> On Wed, Aug 30, 2017 at 10:47 AM, Manoj B. Narayanan <
> >> manojb.narayanan2011@gmail.com> wrote:
> >>
> >>> Hi,
> >>>
> >>> While training a NER model I use provide custom features by
> implementing *AdaptiveFeatureGenerator.
> >>> *In the implementing class I compute certain features and add them.
> When
> >>> I have another implementing class for adding features, I compute the
> >>> features which sometimes are computed in the first implementing class
> >>> itself. I am not aware of a mechanism where I can use the information
> from
> >>> the first implementing class without computing them again.
> >>>
> >>> So, if there is a way where I could store some information about a
> >>> sentence in a global manner, I would be able to get them in all the
> classes
> >>> I need without computing them.
> >>>
> >>> If there is a provision for this already, please guide me. Else, I put
> >>> forth this as a suggestion/request.
> >>>
> >>> Thanks,
> >>> Manoj.
> >>>
> >>>
> >>>
> >
>

Re: Cache

Posted by Joern Kottmann <ko...@gmail.com>.
The feature generators are not thread safe, so it is ok to use an
instance variable for caching.
We have some feature generators which do that.

Jörn

On Tue, Sep 5, 2017 at 9:19 PM, Daniel Russ <dr...@apache.org> wrote:
> Again, you should send this to users not dev mail list.
>
> Have you tried adding an instance variable  (e.g.  numWords) that you update when you call “createFeature”? You need to be concerned with thread safety if you do this on more than 1 thread, but you can synchronize only the part of the code that adds to the instance variable.  You should also be careful to create 1 instance of the AdaptiveFeatureGenerator.
>
> you might also consider resetting the value in the clearAdaptiveData method.  However, that might not work for you and you may need a method to reset your feature.
>
> Let me know if that works for you….
>
> Daniel
>
>> On Sep 5, 2017, at 6:48 AM, Manoj B. Narayanan <ma...@gmail.com> wrote:
>>
>> Hi,
>>
>> Could anyone please help me out.
>>
>> Thanks,
>> Manoj
>>
>> On Wed, Aug 30, 2017 at 10:47 AM, Manoj B. Narayanan <
>> manojb.narayanan2011@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> While training a NER model I use provide custom features by implementing *AdaptiveFeatureGenerator.
>>> *In the implementing class I compute certain features and add them. When
>>> I have another implementing class for adding features, I compute the
>>> features which sometimes are computed in the first implementing class
>>> itself. I am not aware of a mechanism where I can use the information from
>>> the first implementing class without computing them again.
>>>
>>> So, if there is a way where I could store some information about a
>>> sentence in a global manner, I would be able to get them in all the classes
>>> I need without computing them.
>>>
>>> If there is a provision for this already, please guide me. Else, I put
>>> forth this as a suggestion/request.
>>>
>>> Thanks,
>>> Manoj.
>>>
>>>
>>>
>

Re: Cache

Posted by Daniel Russ <dr...@apache.org>.
Again, you should send this to users not dev mail list.

Have you tried adding an instance variable  (e.g.  numWords) that you update when you call “createFeature”? You need to be concerned with thread safety if you do this on more than 1 thread, but you can synchronize only the part of the code that adds to the instance variable.  You should also be careful to create 1 instance of the AdaptiveFeatureGenerator.   

you might also consider resetting the value in the clearAdaptiveData method.  However, that might not work for you and you may need a method to reset your feature.

Let me know if that works for you….

Daniel

> On Sep 5, 2017, at 6:48 AM, Manoj B. Narayanan <ma...@gmail.com> wrote:
> 
> Hi,
> 
> Could anyone please help me out.
> 
> Thanks,
> Manoj
> 
> On Wed, Aug 30, 2017 at 10:47 AM, Manoj B. Narayanan <
> manojb.narayanan2011@gmail.com> wrote:
> 
>> Hi,
>> 
>> While training a NER model I use provide custom features by implementing *AdaptiveFeatureGenerator.
>> *In the implementing class I compute certain features and add them. When
>> I have another implementing class for adding features, I compute the
>> features which sometimes are computed in the first implementing class
>> itself. I am not aware of a mechanism where I can use the information from
>> the first implementing class without computing them again.
>> 
>> So, if there is a way where I could store some information about a
>> sentence in a global manner, I would be able to get them in all the classes
>> I need without computing them.
>> 
>> If there is a provision for this already, please guide me. Else, I put
>> forth this as a suggestion/request.
>> 
>> Thanks,
>> Manoj.
>> 
>> 
>>