To my knowledge, the capabilities are part of the descriptor which must be 
available before the AE is initialized. You cannot retroactively change the
descriptor of a method from within its initialize() method.

It would be nice to have something like this, though. But that would also mean
switching any flow controllers which use this information from a static planning
to a dynamic planning approach.

How about filing a feature request against the UIMA framework?

-- Richard

On 05.12.2013, at 08:35, Renaud Richardet <renaud.richar...@gmail.com> wrote:

> I find it very convenient to add
> 
> @TypeCapability(inputs = { TOKEN, SENTENCE, COOCCURRENCE })
> so that I can ensure that dependencies are met. But sometimes, the
> dependencies are dynamic (e.g. an input type capability is part of the
> config of an annotator, and is loaded dynamically, see code below).
> 
> Is there a way to dynamically set a required annotation type from within a
> UIMAfit annotator? Something like:
> 
>    @Override
> 
>    public void initialize(UimaContext context)
> 
>            throws ResourceInitializationException {
> 
>        super.initialize(context);
> 
>        try {
> 
>            // loading annotation class dynamically
> 
>            requiredAnnotation= (Class<? extends Annotation>) Class.forName(
> "org.uima.MyRequiredAnnotation");
> 
>            // adding it as TypeCapability's input
> 
>            context.getMetadata().addCapabilityInput(requiredAnnotation);
> 
>        } catch (Exception e) {
> 
>            throw new ResourceInitializationException(e);
> 
>        }
> 
>    }
> 
> 
> Thanks, Renaud

Reply via email to