uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Renaud Richardet <renaud.richar...@gmail.com>
Subject how to dynamically set a required annotation type from within a UIMAfit annotator?
Date Thu, 05 Dec 2013 10:35:52 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message