On 6 Aug 2012, at 12:59, Richard Eckart de Castilho wrote:
> Hello Florian,
>
> with vanilla UIMA, there is no other way than casting. You might want to take a look
at uimaFIT though.
>
>> FSIterator<Annotation> annIt = jcas.getAnnotationIndex(myType).iterator();
>
> List<Token> tokens = JCasUtil.select(jcas, Token.class)
>
>> 2. The second type safety issue I have is with external resources. Lets assume I've
got an interface defining a StringMapResource<T>, i.e., much like in the UIMA tutorials,
essentially a Map<String, T> using String keys and some generic values. Usually, in
the initialize(UimaContext ctx) method, I'd write:
>>
>> StringMapResource<MyType> smr = (StringMapResource<MyType>) ctx.getResourceObject(myResourceKey);
>
> This is really a bit difficult to do statically type safe, but uimaFIT allows you to
at least avoid the compiler warnings. You'd just set up a class variable of the type you want
and annotate it with @ExternalResource:
>
> @ExternalResource(key="MY_RESOURCE_KEY")
> private StringMapResource<MyType> smr;
>
> Mind that for this annotation (or the similarliy useful @ConfigurationParameter annotation)
to work either your component must inherit from one of the uimaFIT base classes (e.g. org.uimafit.component.JCasAnnotator_ImplBase)
or you have to call ConfigurationParameterInitializer and ExternalResourceInitializer manually
in initialize().
>
> Cheers,
>
> -- Richard
> --
Hello Richard,
Thank you very much for your responses!
In general, I am already using uimaFIT to write my tests, because UIMA itself seems virtually
"untestable", but I am (so far) reluctant to included it in my main code, too, in the hopes
of minimizing my dependencies, maintenance overhead, and maximizing compatibility (Maybe
I should really over think my decision - I am astonished how fast uimaFIT 1.4 was out, following
the UIMA 2.4.0 release.)
However, as a matter of fact, I am not sure I understand why uimaFIT isn't part of UIMA. I'd
think this stuff is so good it should be included into the Apache code-base.
Regards,
Florian
|