uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Mauceri <mauc...@hermeneute.com>
Subject Re: Iterators in CAS
Date Fri, 12 Oct 2007 08:45:50 GMT
Hi Ekaterina,

if I understood your question, it is possible and even a nice feature of 
UIMA. I have more or less the same problems, I have two types of 
annotations contexts and forms (sentences and token for you). So I have 
TAEs which marks contexts and forms then I have another TAE (a CAS 
consumer in my very simple case) which do the following.:

       // A context
        TCollocation tc = null;
       // A form
        TForm f = null;

       // I first iter over all the annotations
        Iterator annot = 
        while(annot.hasNext()) {
            Annotation a = (Annotation)annot.next();
             // then I test if it is a context TCollocation or a form TForm
            if (a instanceof TCollocation) {
                tc = (TCollocation)a;
            } else if (a instanceof TForm) {
                f = (TForm) a;

That's all the nice thing is that the iterator respects the position 
order in the text and the inclusion hierarchy so you are sure the 
current form belongs to the current context.

I hope it is helpfull and I did not say baloneys, at least works fine 
for me.


Ekaterina Buyko wrote:
> Hi all!
> In UIMA 2.1 it is possible to create a sub-iterator in order to 
> iterate over annotations which are within the begin-end span of the 
> selected type.
> For example:
> AnnotationIndex sentenceIndex = (AnnotationIndex) aJCas 
> .getJFSIndexRepository().getAnnotationIndex(Sentence.type);
> AnnotationIndex tokenIndex = (AnnotationIndex) aJCas
>                .getJFSIndexRepository().getAnnotationIndex(Token.type);
>        // iterate over Sentences
>        FSIterator sentenceIterator = sentenceIndex.iterator();
>        while (sentenceIterator.hasNext()) {
>            Sentence sentence = (Sentence) sentenceIterator.next();
>            // iterate over Tokens
>            FSIterator tokenIterator = tokenIndex.subiterator(sentence);
> I would like to have a more extended functionality. I need to know the 
> annotations which are in the span of begin-end of the selected 
> annotation type. These annotations can overlap the span of the 
> selected type.
> For example noun phrases. If I iterate over tokens, I would like to 
> know, if this token is inside a noun phrase or not. Now, I am working 
> with Hashtables. But I am looking for an other solution.
> How could I solve this problem?
> Bets regards
> Ekaterina

Christian Mauceri

View raw message