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 <[email protected]> > 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 >
