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
>
>