You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by candel <ca...@titus.u-strasbg.fr> on 2007/08/10 14:53:29 UTC

conditional FlowController

Hello,
I am working on a UIMA FlowController.
I would like to guide a CAS through one or another AE depending on the 
result of a first AE.
I think I have to write something like that:

//running first AE
return SimpleStep(aeKey1);
//testing my condition
If (result==”ok”){ return new SimpleStep(aeKey2)}
Else { return new SimpleStep(aeKey3)}
//closing flow
return FinalStep();

The trouble is that I can’t find out how to get the aeKey of a 
particular AE...Is it simply the key name given in the AAE descriptor 
where we join our own defined flow?

Thank you for your help.

Sophie


Re: conditional FlowController

Posted by candel <ca...@titus.u-strasbg.fr>.
Adam Lally wrote:

>Hi Sophie,
>
>
>On 8/10/07, candel <ca...@titus.u-strasbg.fr> wrote:
>  
>
>>Hello,
>>I am working on a UIMA FlowController.
>>I would like to guide a CAS through one or another AE depending on the
>>result of a first AE.
>>I think I have to write something like that:
>>
>>//running first AE
>>return SimpleStep(aeKey1);
>>//testing my condition
>>If (result=="ok"){ return new SimpleStep(aeKey2)}
>>Else { return new SimpleStep(aeKey3)}
>>//closing flow
>>return FinalStep();
>>
>>    
>>
>
>Sort of... but you can only return one Step object per call to the
>next() method, so you have to remember where you are in the flow.  A
>simple way to do this would be like this:
>
>if (!firstAeCalled) {
>  //running first AE
>  firstAeCalled = true;
>  return SimpleStep(aeKey1);
>} else if (!secondAeCalled) {
>  secondAeCalled = true
>  //TODO: compute "result" by looking at the CAS
>  If (result=="ok"){ return new SimpleStep(aeKey2)}
>   Else { return new SimpleStep(aeKey3)}
>} else {
>  //closing flow
>  return FinalStep();
>}
>
>Also look at the exampleWhiteboardFlowController.java, which keeps a
>history of which AEs have been already called during the Flow.
>
>  
>
>>The trouble is that I can't find out how to get the aeKey of a
>>particular AE...Is it simply the key name given in the AAE descriptor
>>where we join our own defined flow?
>>
>>    
>>
>
>
>Yes, the aeKey will be the same as the key defined in the Aggregate
>Analysis Engine descriptor, but it's preferable to query the framework
>for this information rather than hard-coding a particular key value
>into your Flow Controller.
>
>In your FlowController, call:
>getContext().getAnalysisEngineMetaDataMap()
>
>This returns you a Map from aeKey Strings to AnalysisEngineMetaData
>object.  The AnalysisEngineMetaData contains information from that
>particular delegate (component) AE's descriptor - such as its name,
>inputs,outputs, etc.
>
>
>Regards,
>  -Adam
>
>
>
>  
>
thank you for this answer, I am trying it right now!


Re: conditional FlowController

Posted by Marshall Schor <ms...@schor.com>.
candel wrote:
> Adam Lally wrote:
>
>> Hi Sophie,
>>
>>
>> On 8/10/07, candel <ca...@titus.u-strasbg.fr> wrote:
>>  
>>
>>> Hello,
>>> I am working on a UIMA FlowController.
>>> I would like to guide a CAS through one or another AE depending on the
>>> result of a first AE.
>>> I think I have to write something like that:
>>>
>>> //running first AE
>>> return SimpleStep(aeKey1);
>>> //testing my condition
>>> If (result=="ok"){ return new SimpleStep(aeKey2)}
>>> Else { return new SimpleStep(aeKey3)}
>>> //closing flow
>>> return FinalStep();
>>>
>>>   
>>
>> Sort of... but you can only return one Step object per call to the
>> next() method, so you have to remember where you are in the flow.  A
>> simple way to do this would be like this:
>>
>> if (!firstAeCalled) {
>>  //running first AE
>>  firstAeCalled = true;
>>  return SimpleStep(aeKey1);
>> } else if (!secondAeCalled) {
>>  secondAeCalled = true
>>  //TODO: compute "result" by looking at the CAS
>>  If (result=="ok"){ return new SimpleStep(aeKey2)}
>>   Else { return new SimpleStep(aeKey3)}
>> } else {
>>  //closing flow
>>  return FinalStep();
>> }
>>
>> Also look at the exampleWhiteboardFlowController.java, which keeps a
>> history of which AEs have been already called during the Flow.
>>
>>  
>>
>>> The trouble is that I can't find out how to get the aeKey of a
>>> particular AE...Is it simply the key name given in the AAE descriptor
>>> where we join our own defined flow?
>>>
>>>   
>>
>>
>> Yes, the aeKey will be the same as the key defined in the Aggregate
>> Analysis Engine descriptor, but it's preferable to query the framework
>> for this information rather than hard-coding a particular key value
>> into your Flow Controller.
>>
>> In your FlowController, call:
>> getContext().getAnalysisEngineMetaDataMap()
>>
>> This returns you a Map from aeKey Strings to AnalysisEngineMetaData
>> object.  The AnalysisEngineMetaData contains information from that
>> particular delegate (component) AE's descriptor - such as its name,
>> inputs,outputs, etc.
>>
>>
>> Regards,
>>  -Adam
>>
>>
>>
>>  
>>
> Hi,
>
> thanks to your help, I wrote my Conditional FlowController.
> The thing is that I couldn't find an other way than hard-coding the 
> eaKeys in it.
> Indeed, nothing can distinguish the annotators AE2 or AE3 except for 
> their internal analysis method.
> In fact, the analysis method used is only a strategic choice that 
> depends on the results of the first AE.
> AE2 and AE3 have the same inputs and outputs requirements, ...
>
> After these explanations, do you still think their is another way to 
> do it?
>
> Regards,
> Sophie
>
I agree with you - if the only distinction is their "names", then you 
have to use that.

-Marshall

Re: conditional FlowController

Posted by candel <ca...@titus.u-strasbg.fr>.
Adam Lally wrote:

>On 8/14/07, candel <ca...@titus.u-strasbg.fr> wrote:
>  
>
>>Hi,
>>
>>thanks to your help, I wrote my Conditional FlowController.
>>The thing is that I couldn't find an other way than hard-coding the
>>eaKeys in it.
>>Indeed, nothing can distinguish the annotators AE2 or AE3 except for
>>their internal analysis method.
>>In fact, the analysis method used is only a strategic choice that
>>depends on the results of the first AE.
>>AE2 and AE3 have the same inputs and outputs requirements, ...
>>
>>After these explanations, do you still think their is another way to do it?
>>
>>    
>>
>
>OK, that' s probably fine then.  You could also use the Name of the AE
>(AnalysisEngineMetaData.getName()), but it's not clear to me that
>there's any advantage in doing that instead of just using the AE key.
>
>-Adam
>
>
>
>  
>
Thank you for your help.
An other interest in using AEKeys is that it will allow us to write 
reusable FlowController. Then we will just have to change the delegateAE 
import name in the FlowController Descriptor.
In fact we think joining preexisting components to do a new pipeline is 
in the UIMA mind.
ie: a Collection Reader + a FlowController + x AEs +...

Regards,

Sophie


Re: conditional FlowController

Posted by Adam Lally <al...@alum.rpi.edu>.
On 8/14/07, candel <ca...@titus.u-strasbg.fr> wrote:
> Hi,
>
> thanks to your help, I wrote my Conditional FlowController.
> The thing is that I couldn't find an other way than hard-coding the
> eaKeys in it.
> Indeed, nothing can distinguish the annotators AE2 or AE3 except for
> their internal analysis method.
> In fact, the analysis method used is only a strategic choice that
> depends on the results of the first AE.
> AE2 and AE3 have the same inputs and outputs requirements, ...
>
> After these explanations, do you still think their is another way to do it?
>

OK, that' s probably fine then.  You could also use the Name of the AE
(AnalysisEngineMetaData.getName()), but it's not clear to me that
there's any advantage in doing that instead of just using the AE key.

-Adam

Re: conditional FlowController

Posted by candel <ca...@titus.u-strasbg.fr>.
Adam Lally wrote:

>Hi Sophie,
>
>
>On 8/10/07, candel <ca...@titus.u-strasbg.fr> wrote:
>  
>
>>Hello,
>>I am working on a UIMA FlowController.
>>I would like to guide a CAS through one or another AE depending on the
>>result of a first AE.
>>I think I have to write something like that:
>>
>>//running first AE
>>return SimpleStep(aeKey1);
>>//testing my condition
>>If (result=="ok"){ return new SimpleStep(aeKey2)}
>>Else { return new SimpleStep(aeKey3)}
>>//closing flow
>>return FinalStep();
>>
>>    
>>
>
>Sort of... but you can only return one Step object per call to the
>next() method, so you have to remember where you are in the flow.  A
>simple way to do this would be like this:
>
>if (!firstAeCalled) {
>  //running first AE
>  firstAeCalled = true;
>  return SimpleStep(aeKey1);
>} else if (!secondAeCalled) {
>  secondAeCalled = true
>  //TODO: compute "result" by looking at the CAS
>  If (result=="ok"){ return new SimpleStep(aeKey2)}
>   Else { return new SimpleStep(aeKey3)}
>} else {
>  //closing flow
>  return FinalStep();
>}
>
>Also look at the exampleWhiteboardFlowController.java, which keeps a
>history of which AEs have been already called during the Flow.
>
>  
>
>>The trouble is that I can't find out how to get the aeKey of a
>>particular AE...Is it simply the key name given in the AAE descriptor
>>where we join our own defined flow?
>>
>>    
>>
>
>
>Yes, the aeKey will be the same as the key defined in the Aggregate
>Analysis Engine descriptor, but it's preferable to query the framework
>for this information rather than hard-coding a particular key value
>into your Flow Controller.
>
>In your FlowController, call:
>getContext().getAnalysisEngineMetaDataMap()
>
>This returns you a Map from aeKey Strings to AnalysisEngineMetaData
>object.  The AnalysisEngineMetaData contains information from that
>particular delegate (component) AE's descriptor - such as its name,
>inputs,outputs, etc.
>
>
>Regards,
>  -Adam
>
>
>
>  
>
Hi,

thanks to your help, I wrote my Conditional FlowController.
The thing is that I couldn't find an other way than hard-coding the 
eaKeys in it.
Indeed, nothing can distinguish the annotators AE2 or AE3 except for 
their internal analysis method.
In fact, the analysis method used is only a strategic choice that 
depends on the results of the first AE.
AE2 and AE3 have the same inputs and outputs requirements, ...

After these explanations, do you still think their is another way to do it?

Regards,
Sophie


Re: conditional FlowController

Posted by Adam Lally <al...@alum.rpi.edu>.
Hi Sophie,


On 8/10/07, candel <ca...@titus.u-strasbg.fr> wrote:
> Hello,
> I am working on a UIMA FlowController.
> I would like to guide a CAS through one or another AE depending on the
> result of a first AE.
> I think I have to write something like that:
>
> //running first AE
> return SimpleStep(aeKey1);
> //testing my condition
> If (result=="ok"){ return new SimpleStep(aeKey2)}
> Else { return new SimpleStep(aeKey3)}
> //closing flow
> return FinalStep();
>

Sort of... but you can only return one Step object per call to the
next() method, so you have to remember where you are in the flow.  A
simple way to do this would be like this:

if (!firstAeCalled) {
  //running first AE
  firstAeCalled = true;
  return SimpleStep(aeKey1);
} else if (!secondAeCalled) {
  secondAeCalled = true
  //TODO: compute "result" by looking at the CAS
  If (result=="ok"){ return new SimpleStep(aeKey2)}
   Else { return new SimpleStep(aeKey3)}
} else {
  //closing flow
  return FinalStep();
}

Also look at the exampleWhiteboardFlowController.java, which keeps a
history of which AEs have been already called during the Flow.

> The trouble is that I can't find out how to get the aeKey of a
> particular AE...Is it simply the key name given in the AAE descriptor
> where we join our own defined flow?
>


Yes, the aeKey will be the same as the key defined in the Aggregate
Analysis Engine descriptor, but it's preferable to query the framework
for this information rather than hard-coding a particular key value
into your Flow Controller.

In your FlowController, call:
getContext().getAnalysisEngineMetaDataMap()

This returns you a Map from aeKey Strings to AnalysisEngineMetaData
object.  The AnalysisEngineMetaData contains information from that
particular delegate (component) AE's descriptor - such as its name,
inputs,outputs, etc.


Regards,
  -Adam

Re: conditional FlowController

Posted by Michael Baessler <mb...@michael-baessler.de>.
I think you will find your answer in the WhiteboardFlowController.java 
example. See a snapshot below:

      // iterate over available AEs
      Iterator aeIter = 
getContext().getAnalysisEngineMetaDataMap().entrySet().iterator();
      while (aeIter.hasNext()) {
        Map.Entry entry = (Map.Entry) aeIter.next();
        // skip AEs that were already called on this CAS
        String aeKey = (String) entry.getKey();
        ......

Yes the used AE keys are the AAE keys that refers the primitive AEs.

-- Michael

candel wrote:
> Hello,
> I am working on a UIMA FlowController.
> I would like to guide a CAS through one or another AE depending on the 
> result of a first AE.
> I think I have to write something like that:
>
> //running first AE
> return SimpleStep(aeKey1);
> //testing my condition
> If (result==”ok”){ return new SimpleStep(aeKey2)}
> Else { return new SimpleStep(aeKey3)}
> //closing flow
> return FinalStep();
>
> The trouble is that I can’t find out how to get the aeKey of a 
> particular AE...Is it simply the key name given in the AAE descriptor 
> where we join our own defined flow?
>
> Thank you for your help.
>
> Sophie
>
>
>