On 1/11/2010 11:48, Tommaso Teofili wrote:
> Hi Jerome,
> Why not using FilteredIterator (which extends FSIteratorImplBase) ?
> Using the FSMatchConstraint interface you can then define your own
> constraint.

I agree with Tommaso, that may be your best approach.

The general contract for remove() on an iterator is
that it removes the element from the underlying
collection, which in this case is the CAS annotation
index.  Not sure if that is what you want, or you just
want to remove it from the iterator.  If you want it
removed from the iterator, follow Tommaso's suggestion.
If you want to remove it from the index, see Marshall's
note.

--Thilo

> Hope this helps.
> Tommaso
> 
> 2010/1/11 Jérôme Rocheteau <[email protected]>
> 
>> 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
>>
> 

Reply via email to