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

I tried this workaround but found it to be very slow (moveToPrevious()
seems to be a costly operation). Since I didn't want to add dummy types
and type priorities as Matthias suggested I found a simple and fast
workaround:
- create a dummy annotation D of same type as annotation A to be test for
- set D.begin=A.begin and D.end=A.end+1
  (thus make sure D comes before all annotations we are interested in)
- in case moveTo(D) really found an annotation of this range use next()
  until it reaches the desired range (cheap operation)
now the iterator points to the correct start of annotations with
boundaries identical to A

Timo

> 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
>>>
>>>
>>>   


 Timo Boehme
 OntoChem GmbH
 H.-Damerow-Str. 4
 06120 Halle/Saale
 T: +49 345 4780472
 F: +49 345 4780471
 [email protected]

_____________________________________________________________________

 OntoChem GmbH
 Geschäftsführer: Dr. Lutz Weber
 Sitz: Halle / Saale
 Registergericht: Stendal
 Registernummer: HRB 215461
_____________________________________________________________________

Reply via email to