Yes, That's what I did with the AnnotationWrapper class I wrote (see my
other messages on that same thread).

It's a bit hacky, so I was hoping that there was a more UIMA native
solution to this problem.

On Mon, Nov 18, 2019 at 12:33 PM Olga Patterson <olga.patter...@utah.edu>
wrote:

> If you just want an easier way to manipulate annotations, you can have a
> utility class that would have all methods separate from the annotation types
> Example code from
> http://decipher.chpc.utah.edu/nexus/index.html#nexus-search;classname~Annotationlibrarian
> <dependency>
>   <groupId>gov.va.vinci</groupId>
>   <artifactId>leo-annotation-librarian</artifactId>
>   <version>2018.01.0</version>
> </dependency>
>
>
>
> On Nov 15, 2019, at 10:58 AM, Marshall Schor <m...@schor.com> wrote:
>
> Even though the JCas classes can be generated from the XML file, you are
> allowed
> to add additional things to those source files, including
>
>    - additional fields
>
>    - additional methods
>
> See
>
> http://uima.apache.org/d/uimaj-2.10.4/references.html#ugr.ref.jcas.augmenting_generated_code
>
> -Marshall
>
> On 11/15/2019 9:50 AM, Alain Désilets wrote:
> On Thu, Nov 14, 2019 at 4:51 PM Richard Eckart de Castilho <r...@apache.org
> >
> wrote:
>
> Sure. You generate the JCas classes once and then you add the methods you
> want
> to them. Cf. e.g.
>
>
>
> https://github.com/dkpro/dkpro-core/blob/8043e10bf10a61fe47e21946ea609bda9f2278a0/dkpro-core-api-metadata-asl/src/main/java/de/tudarmstadt/ukp/dkpro/core/api/metadata/type/DocumentMetaData.java#L290-L447
>
> I know how to create a subclass of Annotation, RelationAnnotation in my
> case. The problem is that if I try to use this subclass in an Annotator,
> UIMA complains that RelationAnnotation is not in the UIMA type system, and
> it lists the available types. This list is essentially the list of types
> defined in some UIMA xml file. This tells me that only those annotation
> classes defined in the xml file can be used in an Annotator. Or at least,
> that I am missing a step for registering my RelationAnnotation class with
> the UIMA type system.
>
> On the other hand, if I define the RelationAnnotation in the xml file, I
> can use it in an Annotator but then I can't figure out how to add methods
> to it, since the Java source for that class is generated automatically (by
> some UIMA maven plugin I presume).
>
> But the question is: why do you want to add new methods? (and is it really
> a good idea?)
>
> Essentially, I want to add methods for "derived attributes", i.e.
> attributes whose values are computed from primitive attributes defined in
> the xml file.
>
> I guess I could make those attributes be primitve (i.e. defined in the xml
> file), but then, any annotator that creates a RelationAnnotation would have
> to make sure to set those other attributes correctly. I would much rather
> have the RelationAnnotation class compute those derived attributes itself,
> as it garantees that they will always be computed the same way.
>
> Alain
>
>

Reply via email to