Hi,
On 15. Dec 2018, at 13:11, Alain Désilets <
alainde...@gmail.com> wrote:
>
> Not sure if this is the right place to ask that question (maybe it belongs more in a UIMA-specific forum), but is it possible to create dynamically typed annotations in UIMA? In other words, would it possible for users of my system to create a new type of annotation without having to recompile the Java code?
>
> I need this functionality so that non-dev users can define new types of Named Entities and train a model that can recognize them without having to recompile the code.
I wouldn't recommend defining new types but rather use an attribute on a generic type in order to hold the value.
E.g. `NamedEntity` is our generic type for named entities and the `value` feature is where you put whatever you like in terms of labels.
> I suspect the answer is no, because all annotation types correspond to a Java class. True, those classes are defined in an XML file, but in order to use them you have to generate the Java code from the XML and recompile your code.
The Java classes are just a convenience. You can use UIMA fully without them by using the CAS API instead of the JCas API.
> If UIMA does not yet have something that supports dynamic annotations, I will have to implement one myself. Maybe this could be an interesting addition to DKPro?
It is possible - but not necessarily fast - to redefine a CAS to a new type system. I have posted a piece of code that I am using for this purpose as a response to your mail on the UIMA users mailing list.
> What I have in mind is to define a sub-class of Annotation called say, DynamicallTypedAnnotation, which would have two new member variables:
>
> String typeName = null;
> Map<String,Object> attributes = new HashMap<String,Object>();
>
> The 'typeName' variable would correspond to the type of the annotation (ex: "Room Number" for an annotation that captures the number of a room) and the 'attributes' variable would allow storage of arbitrary information about the annotation.
>
> Does that make sense?
Depending on the use-case, it may make sense or not. I personally tend towards not using that approach and instead defining additional types, upgrading the CAS to be able to handle them, and using the CAS API. Works for me ;)
Cheers,
-- Richard