Just to clarify: the moveTo() method tries to move the
iterator to a position such that the annotation at the
position is equal to the one you're looking for.  If
there is more than one such annotation, it is undefined
which one the iterator will point to.

Is this consistent with the API docs?  I would say it
isn't.  We say "move the iterator to the first FS...".
Intuitively, that should mean to the "leftmost" FS, but
in fact it is implemented to mean the first one that
the algorithm finds, which will generally _not_ be the
leftmost one.

As a workaround, you can moveToPrevious() until you hit
an annotation that is not equal to the one you're looking
for.

I think we should fix this, you're not the first one to
complain.  Please open a Jira issue, and we can look
into it after the upcoming release.

--Thilo

Matthias Wendt wrote:
> Hi Timo,
> 
> the order relation of the feature structures is defined by the index
> definition. Have a look at the index definition of the (built-in)
> annotation index. You can if you open any annotator descriptor using the
> component editor in eclipse. This helped me a lot in understanding the
> behaviour of the iterators.
> 
> To put it short, if two annotations of the same type have exactly the
> same boundaries, the behaviour is indeed unspecified. However, you can
> avoid this indeterminism, by adding a second type and assigning it a
> higher priority. If you don't need a second type, you can use it as a
> helper, shifting an instance across the CAS as needed ;) - at least, I
> don't know of any more elegant method.
> 
> -- Hope this helps
> 
> Matthias
> 
> 
> 
> 
> Timo Boehme schrieb:
>> Hi,
>>
>> in my scenario there may be multiple annotations of same type for the
>> same region. Before I add an annotation I would like to check if such an
>> annotation already exists.
>>
>> To accomplish this I use  FSIndex.iterator( newAnnotation ) to get an
>> iterator which starts at the position of my new (but not added)
>> annotation. According to the method description the iterator should be
>> positioned so that previous annotations are less compared to
>> newAnnotation.
>>
>> However sometimes if I call moveToPrevious() (directly after iterator
>> creation) I will get (with get()) an annotation (of same type) with same
>> region as newAnnotation - which in my opinion is not less.
>>
>> Thus I would like to know if annotations of same type for same region
>> will trigger some 'unspecified' behavior or if my understanding of the
>> iterator is wrong or if I stumbled upon a bug?
>>
>>
>> Kind regards
>> Timo
>>
>>
>>   
> 

Reply via email to