Hi, Here are a couple of approaches:
1) Leave the annotations in the CAS (do not remove them from the CAS) but have your method which iterates over these "skip" over the ones that should not be processed. This way, the user of your iterator method gets just those annotations that are wanted. 2) If you desire to remove them from the CAS (actually, to remove them from the CAS indexes), because you do not want them to be found by subsequent plain, ordinary CAS iterators, then you could do this in two steps: a) first, do an iteration which finds all the items to be removed, and add these to some kind of Java collection, for instance, an ArrayList. Then, b) use an ordinary Java Collection iterator over the collection, to remove these from the CAS indexes, so they won't be found on subsequent uses of normal CAS iterators. Note that the remove operation for Feature Structures doesn't actually remove the annotations from the CAS, but instead, just removes them from the CAS indexes (for that particular view). Hope that helps. -Marshall Jérôme Rocheteau wrote: > Hi everybody, > > I would like to apply several constraint filters to an annotation iterator > and, > especially, to select annotations which covered text matches a given text. > So I'm thinking of defining a method that iterates and removes annotations > which covered text doesn't match the given text from a > FSIterator<Annotation>. > > However, an exception UnsupportedOperationException occurs while calling the > remove method (because of its definition in the FSIteratorImpl class, I > guess). > > So I would like to know how to (un)select annotations of such an object: > * either by implementing the remove method of the FSIteratorImpl class, > * or by casting a java.util.Iterator<E> to org.apache.uima.cas.FSIterator<E>, > * or by building such an iterator from annotation lists, > * or something else. > > Do you have any hints? > > Thanks in advance, > Jérôme > > >
