uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marshall Schor <...@schor.com>
Subject Re: Retrieving annotator back from analysis engine
Date Thu, 30 Mar 2017 21:26:30 GMT
Hi James,

Although you might be able to find some chain of references to eventually get
what you want, it would end up being very brittle, subject to change from
release to release without warning etc.

A more general approach, that's immune to these would be to just create a user
map in your application code which is calling produceAnalysisEngine, so at the
next line it adds to this map a key (which is the analysis engine) and a value
(which is the resourceSpecifier used to create the Analysis Engine) (which in
your special case, is also the subclass of MyAnnotator, as I understand it).

Then whenever you need to go from the Analysis Engine to the MyAnnotator
instance, you just look it up in this map.


On 3/30/2017 10:24 AM, James Baker wrote:
> Thanks Marshall,
> What I have is each annotator wrapped as a separate analysis engine
> ("pipeline"), and then I'm manually running each of those in turn because I
> want to be able to control the order. In fact, what I'm really trying to
> achieve is controlling the order that the annotators are run in, based
> information I get back from them.
> Surely the analysis engine/resource specifier must have some kind of
> reference back to the original class, otherwise how does it know what code
> to run? Perhaps there's not a method at the moment to get back to the
> original annotator, but is it stored somewhere I could get to via
> reflection (accepting all the risks and bad practices that entails!)
> James
> On 30 March 2017 at 15:07, Marshall Schor <msa@schor.com> wrote:
>> Hi James,
>> The UIMA terminology discusses two kinds of entities:
>>   a) Annotators - take a CAS in, operate on it, update it, etc.  These are
>> the
>> building blocks of pipelines.
>>   b) UIMA Applications (e.g., "pipelines") made up of some collection of
>> Annotators.
>> In most UIMA applications, there might be 1 pipeline, each having a number
>> of
>> Annotators. Is this what you have?  Or are you running multiple (perhaps
>> different) collections of annotators, each having its own pipeline?
>> The produceAnalysisEngine call takes an object which is a
>> ResourceSpecifier.
>> That object is a description of the entire pipeline - what annotators are
>> in it,
>> configuration parameters, etc.  The output of that is an AnalysisEngine
>> object
>> that represents the whole pipeline.
>> There's no reference from that AnalysisEngine object back to the
>> ResourceSpecifier that was used to direct the construction of the pipeline.
>> So, I don't think what you want to do can be done.
>> ============
>> That being said, perhaps the high level design can be adjusted.  I'm
>> wondering
>> if two things got a bit conflated in the design - the idea of analysis
>> engine
>> "components" (e.g. Annotators) and the idea of analysis engines themselves
>> (the
>> pipelines that contain the annotators, configuration data, etc.)?
>> -Marshall
>> On 3/29/2017 1:11 PM, James Baker wrote:
>>> In my UIMA application, I have a number of AnalysisEngines (as you might
>>> expect). These were created using UIMAFramework.
>> produceAnalysisEngine(...)
>>> on my annotators, which all extend MyAnnotator (which in turn extends
>>> JCasAnnotator_ImplBase).
>>> I want to get from the AnalysisEngine back to the original class (cast to
>>> MyAnnotator) so that I can access some of the additional functions I've
>>> added to the class. However, I can't seem to work out how to do that.
>> Could
>>> someone give some pointers?
>>> For clarity, I've included below some code of what I'm trying to acheive
>>> (I'm aware that the code below doesn't work as I've tried it!)
>>> ----------------------------
>>> AnalysisEngine ae = getAnalysisEngine(); //Get the analysis engine from
>>> whereever it is, this bit's not important
>>> MyAnnotator ma = (MyAnnotator) ae; //Throws ClassCastException
>>> ma.callMyFunction(); //This is what I'm really trying to get to
>>> ----------------------------
>>> Thanks,
>>> James

View raw message