You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Hansart Charlotte <ha...@gmail.com> on 2017/09/05 18:58:30 UTC

Re: How to use Language Flow Controller ?

Hi Richard,

Thank you for your answer (and sorry for my delayed answer).

FIRST QUESTION
As you suggested, I went deeper into the LanguageCapabilityFlowController
code, and it seems the initialize() method doesn't work as it should.
Indeed, the part in bold (see below) returns a Capability[] array of length
0. Consequently, the FlowTable couldn't contain any engine ...

public void initialize(FlowControllerContext aContext)
    throws ResourceInitializationException
  {
    super.initialize(aContext);
    this.mComponentMetaDataMap = aContext.getAnalysisEngineMetaDataMap();

    this.mStaticSequence = new ArrayList();

    CapabilityLanguageFlow flowConstraints =
(CapabilityLanguageFlow)aContext.getAggregateMetadata().getFlowConstraints();
    for (String aeKey : flowConstraints.getCapabilityLanguageFlow()) {
      this.mStaticSequence.add(new AnalysisSequenceCapabilityNode(aeKey,


((AnalysisEngineMetaData)this.mComponentMetaDataMap.get(aeKey)).getCapabilities(),
null));
    }
    this.mFlowTable = computeFlowTable(
*aContext.getAggregateMetadata().getCapabilities()*);
  }

Regarding the code I pasted in my last email, could you help me on how I
have to set up the metadata for my aggregated engine(s), so as I can access
them in this function ?

SECOND QUESTION
To by-pass the problem mentioned above, I created a custom Capability[]
array, I filled it thanks to a loop and I passed it to this
computeFlowTable() function (see below).

public void initialize(FlowControllerContext aContext) throws
ResourceInitializationException {
    super.initialize(aContext);
    this.mComponentMetaDataMap = aContext.getAnalysisEngineMetaDataMap();

    // build a list of AnalysisSequenceNodes from the capabilityLanguageFlow
    this.mStaticSequence = new ArrayList<AnalysisSequenceCapabilityNode>();
    CapabilityLanguageFlow flowConstraints = (CapabilityLanguageFlow)
aContext.getAggregateMetadata().getFlowConstraints();
    *Capability[] temp = new Capability[7];*

    int i = 0;
    for (String aeKey : flowConstraints.getCapabilityLanguageFlow()) {
    *for(Capability c: mComponentMetaDataMap.get(aeKey).getCapabilities())
{*
*    System.out.println("C[" + aeKey + "]: ");*
*    temp[i++] = c;*
*    for(String s : c.getLanguagesSupported()) {*
*    System.out.println("Supported Language: " + s);*
*    }*
*    } *
      mStaticSequence.add(
          new AnalysisSequenceCapabilityNode(
              aeKey,

((AnalysisEngineMetaData)this.mComponentMetaDataMap.get(aeKey)).getCapabilities(),
              null));
    }

    // compute flow table with the specified capabilities
    //this.mFlowTable =
computeFlowTable(aContext.getAggregateMetadata().getCapabilities());
    mFlowTable = computeFlowTable(*temp*);
  }

Here is what I get (see below in bold) if I print each Capability object (I
just copied and pasted one of them). Does it look right, according to you ?
I'm not sure the way I set language capabilities for my Annotators is the
right one.

*org.apache.uima.resource.metadata.impl.Capability_impl: *
*description = NULL*
*inputSofas = Array{}*

*inputs = Array{}*

*languagesSupported = Array{0: en*
*}*

*mimeTypesSupported = Array{}*

*outputSofas = Array{}*

*outputs = Array{}*

*preconditions = Array{0:
org.apache.uima.resource.metadata.impl.LanguagePrecondition_impl: *
*comparisonValue = Array{0: en*
*}*

*default = false*
*featureName = language*
*fsIndexName = NULL*
*fsMatchConstraint = isa ( uima.tcas.DocumentAnnotation )*
*languages = Array{0: en*
*}*

*predicate = LanguageSubsumed*

*}*

THIRD QUESTION
I'm really lost with this Flow Controller question. I find this feature
really interesting for what I have to do, so I would be really glad if I
could make it working ! Maybe do you know someone who used it already, and
who could maybe give me an example of how it works ?

Thank you very much for your time and your answers,

Regards,

Charlotte

2017-08-23 20:27 GMT+02:00 Richard Eckart de Castilho <re...@apache.org>:

> Hi Charlotte,
>
> On 23.08.2017, at 07:36, Hansart Charlotte <ha...@gmail.com>
> wrote:
> >
> > Hello all,
> >
> > I'm using UIMA and UIMAfit for some months now, and I'm trying to go
> deeper
> > into its functionalities. These days, I'm trying to use the Language Flow
> > Controller, but it is not really successful, and I have some questions.
> >
> > So my first question is : when multiple AnalysisEngines are aggregated
> > together, are their capabilities "merged" and added to the capabilities
> of
> > the AggregateAnalysisEngine ?
>
> They are not merged. If you need to expose capabilities on the aggregate,
> you'd have to add them there manually. It wouldn't make sense to merge
> them.
> Imagine you have one component that is able to process "de" and "en"
> and another one that can process "en" and "fr", then a good guess may
> be that the aggregate can at least do "en" - but then there may be other
> reasons why this is not the case, e.g. because one of them translates
> from "de" to "en" and the other from "en" to "fr"... I don't think there
> is a sensible merging strategy that uimaFIT should do by default.
> Deferring capabilities of aggregates to the creator of the aggregate
> seems more reasonable to me.
>
> > In each Annotator, I also set the Language Capability parameter :
> >
> > *@LanguageCapability({"en", "de"})*
> > *public class Annotator1 extends JCasAnnotator_ImplBase { ... }*
>
> Since you manually set the capabilities in your code, you override the
> capabilities that uimaFIT adds based on the @LanguageCapability annotation.
> Either of the two (manually adding or using the annotation) should suffice.
>
> > Unfortunately, the code doesn't work, namely, the JCas is not processed
> by
> > the pipeline, and I get any error.
>
> Just looking at the code, I don't see anything blatantly wrong, but I
> also have rarely used a custom flow controller. I can see that you pass
> the AED as a single parameter to runPipeline which is good for what
> you are trying to achieve. Best would be you set a breakpoint in the code
> of the Language Flow Controller and try figuring out whether it doesn't
> find the capabilities, or what else might be going wrong.
>
> Cheers,
>
> -- Richard