On 6/26/07, Philip Ogren <[EMAIL PROTECTED]> wrote:
Thilo had pointed me towards the method typeSystemInit() in a recent
posting as a way of getting type system information in an annotator.  Is
there a reason that this method exists in CasAnnotator_ImplBase but not
JCasAnnotator_ImplBase?  Or is this an omission?  My intuition is that
might have been left out on purpose because when using the JCas you
typically would have a fixed type system that is determined at compile
time. Still, it seems useful to be able to override typeSystemInit()
even if it is only called once.  I didn't really think carefully about
which Annotator_ImplBase I should use.  Are there far reaching
consequences I should consider - or is it really just about convenience
at the API level?


Yes, I think this was left out because JCas-annotators don't need to
acquire Type and Feature handles in the same way that CAS-annotators
do.  Maybe that was a mistake.

The logic in CasAnnotator_ImplBase to determine if the type system
changed is pretty simple - in each call to process(CAS) it just calls
the following method to checksif CAS.getTypeSystem() is == to the type
system of the CAS it got last:

 /**
  * Checks it the type system of the given CAS is different from the
last type system this
  * component was operating on. If it is different, calls the
typeSystemInit method on the
  * component.
  */
 private void checkTypeSystemChange(CAS aCAS) throws
AnalysisEngineProcessException {
   TypeSystem typeSystem = aCAS.getTypeSystem();
   if (typeSystem != mLastTypeSystem) {
     typeSystemInit(typeSystem);
     mLastTypeSystem = typeSystem;
   }
 }


So a workaround is to just copy this logic to your annotator.

-Adam

Reply via email to