Philip Ogren wrote:
> In the tutorial there is a section titled "Retaining references to JCas
> objects between calls to process()" which tells you not to retain
> references to JCas objects.  Is this also true for Type objects?  My
> guess is that it is fine to hold a reference between calls to process()
> so long as you are not changing the type system (and I'm not certain
> that it would be a problem then.)  It doesn't seem that TypeImpl knows
> anything about the CAS or the JCas and so holding a reference should be
> safe.  Is this correct?
> 
> Thanks,
> Philip

Yes, that's correct.  In an annotator, there's a typeSystemInit() method,
where you can acquire all Type and Feature instances you need
for processing.  You can do this on every process() call, but it's not
necessary.  The framework will call the annotator's typeSystemInit()
method every time the type system changes, which is not at all normally.
So normally, typeSystemInit() will be called once, before the first call
to process().

This is briefly described in the developer's guide:
1.5.1. Contract: Annotator Methods Called by the Framework

--Thilo

Reply via email to