You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Eric Riebling <er...@cs.cmu.edu> on 2009/12/08 16:11:06 UTC

Annotation vs. FeatureStructure: CAS Consumer in Aggregate AE

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.


Re: Annotation vs. FeatureStructure: CAS Consumer in Aggregate AE

Posted by Eric Riebling <er...@cs.cmu.edu>.
Eric Riebling <er...@...> writes:

AHA!  All this can be fixed by simply obtaining a JCas representation of the CAS
in the CAS Consumer's processCas() method.  This is an oldie but goodie come
back to haunt me.  Yes for goodness sake, use a JCas, and things work so much
better. :)


Re: Annotation vs. FeatureStructure: CAS Consumer in Aggregate AE

Posted by Thilo Goetz <tw...@gmx.de>.
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