On 23.07.2015, at 19:17, Joern Kottmann <[email protected]> wrote:

> With my CAS-like thing I can just write cas.getIndex("index37",
> EmailAddressAnnotation.class) and it just returns them as Java objects
> of type EmailAddressAnnotation. 
> 
> In a different place in the system the code might only assume its an
> annotation and retrieves the same index as objects of type AnnotationFS.
> cas.getIndex("index37", AnnotationFS.class)

This sounds like the kind of API that uimaFIT supports on top of uimaj-core in 
JCasUtil:

for (EmailAddressAnnotation : select(jcas, EmailAddressAnnotation.class)) {
  ...
}

for (Annotation : select(jcas, Annotation.class)) {
  ...
}

The recent changes in uimaj-core allow almost the same now:


for (EmailAddressAnnotation t : 
jcas.getAnnotationIndex(EmailAddressAnnotation.class)) {
  ...               
}

However, as far as I see it neither uimaFIT nor UIMA currently provide this 
kind of API for custom indexes - should be easy to add.

> UIMA doesn't make it easy with its static type system to write generic
> code working with CASes.

It is not possible (without hacks) to add features or types during pipeline 
execution. But since you appear to be working with pre-defined (Java) classes 
(similar to JCas wrappers), I don't see a problem. You have to know your Java 
classes at build time, so why is it not possible to know the typesystem at 
build time?

-- Richard

Reply via email to