uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Armin.Weg...@bka.bund.de>
Subject AW: Annotation/Feature creation, changing types
Date Wed, 07 Dec 2011 06:26:59 GMT
Hi Tomas,

you can get rid of the Java classes for annotation types by using CAS instead of JCas. This
is a little less comfortable than with JCas. But you still need to have a type system. With
CAS you can generate new types at runtime. This is very nice for testing with JUnit. But I
don't think that you can do it from within an annotator. Has anyone tried to do this?

Regards,

Armin

-----Urspr√ľngliche Nachricht-----
Von: Thilo Goetz [mailto:twgoetz@gmx.de] 
Gesendet: Dienstag, 6. Dezember 2011 22:04
An: user@uima.apache.org
Betreff: Re: Annotation/Feature creation, changing types

On 06/12/11 20:47, Tomas By wrote:
> Hi all,
> 
> I am wondering if it is possible to (for example) first create an 
> annotation or a feature that has no type, and then set the type in a second step.
> 
> From looking at the docs, it seems there is no obvious way to do this.

Correct, there is no way to do this.  Every FS must have a type, and you must specify that
type when you create the FS.

> 
> I want this for two reasons: (1) I have a lexicon lookup module that 
> reads annotation and attribute (ie feature) types as part of the data, 
> and (2) I want to not have to recompile this module every time the 
> UIMA type system changes. Put another way, I want the lexicon lookup 
> module to be totally independent of the type system. If the user 
> provides lexicon data that is not compatible with the type system, 
> then that should (I suppose) trigger an error at module initialization.
> 
> So suppose my data looks like this:
> 
> "word" ANNOTATIONTYPE [ MYTYPE = VALUE, ... ] ...
> 
> Then for every occurrence of "word" in the text, the module adds an 
> annotation of the type ANNOTATIONTYPE with the given attributes.
> 
> At the moment, I have a long conditional that looks like this:
> 
> | if (atp.equals(\"MYTYPE\")) {
> |   a.setMytype(value);
> | }
> 
> That is, I have a hard-coded, type-system-specific mapping from 
> strings that are names of types, to the UIMA Java objects of the same name.
> 
> Is there any way to do this in a more general way so that it is 
> independent of the type system?

Not in any way that still makes use of the UIMA data structures.  UIMA is statically typed,
so there's really no way to dynamically add features at runtime.

You can do the usual trick and emulate a map by, for example, having two parallel arrays,
one with the feature names and the other one with the values.  A bit cumbersome, but doable
if that satisfies your requirement.

You would make all structures of the same annotation type.

Does that make sense?

--Thilo

> 
> /Tomas
> 
> 



Mime
View raw message