uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thilo Goetz <twgo...@gmx.de>
Subject Re: Annotation vs. FeatureStructure: CAS Consumer in Aggregate AE
Date Tue, 08 Dec 2009 16:17:05 GMT
On 12/8/2009 16:11, Eric Riebling wrote:
> I'm running a UIMA-AS aggregate that consists of a single annotator, and a Base
> UIMA Collection Reader and CAS Consumer.  I configure the annotator and CAS
> Consumer as an Aggregate AE, and send it CASes using runRemoteAsyncAE,
> specifying the Collection Reader.
>
> The CAS Consumer works fine with base UIMA, but when running it this way as
> "pure UIMA-AS" it has trouble in the code which reads annotations out of the
> CAS's AnnotationIndex.  Specifically, it gets a ClassCastException:
>
> Caused by: java.lang.ClassCastException: org.apache.uima.cas.impl.AnnotationImpl
>
> in the code that iterates through the AnnotationIndex:
>
> AnnotationIndex idx = (AnnotationIndex) aCAS.getAnnotationIndex( wordType );
> Iterator<Annotation>  it = idx.iterator();
> 		
> // for each word
> while ( it.hasNext() ) {
>    Annotation a = (Annotation) it.next();
>
> I'm confused by a couple of points:
>
> 1.  How come the code works fine with base UIMA if there's a type casting issue
>
> 2.  Since the default type returned by the next() method of an annotation
> iterator is normally a FeatureStructure, it seems that I should use
> FeatureStructures, not Annotations.  How do I go about obtaining the same
> information I would have gotten from Annotations, such as from
> Annotation.getBegin(), Annotation.getCoveredText(), etc.?  Those methods are not
> present on FeatureStructure, as far as I can tell.

I don't know the answer to your first question, that's
for the UIMA AS experts to answer.  To you second question:
an Annotation is a FeatureStructure with two int value
features, begin and end.  You can access those like any
other int valued features.  All the rest is just convenience.
So a.getCoveredText() for example is simply
cas.getDocumentText().substring(begin, end).

--Thilo

Mime
View raw message