Return-Path: Delivered-To: apmail-incubator-uima-user-archive@minotaur.apache.org Received: (qmail 79158 invoked from network); 8 Dec 2009 16:17:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Dec 2009 16:17:36 -0000 Received: (qmail 20421 invoked by uid 500); 8 Dec 2009 16:17:35 -0000 Delivered-To: apmail-incubator-uima-user-archive@incubator.apache.org Received: (qmail 20336 invoked by uid 500); 8 Dec 2009 16:17:34 -0000 Mailing-List: contact uima-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: uima-user@incubator.apache.org Delivered-To: mailing list uima-user@incubator.apache.org Received: (qmail 20326 invoked by uid 99); 8 Dec 2009 16:17:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Dec 2009 16:17:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of twgoetz@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 08 Dec 2009 16:17:25 +0000 Received: (qmail invoked by alias); 08 Dec 2009 16:17:04 -0000 Received: from deibp9eh1--blueice3n1.emea.ibm.com (EHLO [9.152.14.84]) [195.212.29.179] by mail.gmx.net (mp064) with SMTP; 08 Dec 2009 17:17:04 +0100 X-Authenticated: #25330878 X-Provags-ID: V01U2FsdGVkX1+h0idc39Ohss5HbAkVVwdjL6AjnrSHjqN2E8u2N2 7DqZfs0mcHEkAm Message-ID: <4B1E7C01.1040201@gmx.de> Date: Tue, 08 Dec 2009 17:17:05 +0100 From: Thilo Goetz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091130 Thunderbird/3.0 MIME-Version: 1.0 To: uima-user@incubator.apache.org Subject: Re: Annotation vs. FeatureStructure: CAS Consumer in Aggregate AE References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.58 X-Virus-Checked: Checked by ClamAV on apache.org 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 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