Bug in Annotation application when select duplicate text

If i try to make annotation for duplicate section of text it assign to first entry of this text.

  1. image
    2 make annotation
    image
    3 it assignet to top paragraph
    image

Hello urs19work (Roman?),

The annotations system does have a context storage in order to place correctly an annotation based on the surrounding text (and not only on the annotated words), and an algorithm exists for detecting this context when adding an annotation. This algorithm uses an incremental method, so that it detects the shorter possible such context that makes the annotation unique; a context too large would be sensitive to any change, even in parts of the document completely unrelated to the annotation, and make the identification of the annotation fail. So we’re trying to find the “middle ground” between one risk and the other.

In some cases this algorithm fails to find a context that is unique, even by expanding the context a couple of times, and the result is that the annotation is placed on the first occurrence of that context, not on the second one. This case that you found is one of those cases, and it’s related to the fact that the exact same paragraph, which is also rather long, appears twice in the document.
The principle of this algorithm is to cover the best possible the real-life situations, but not necessarily all test situations (there are lots of test cases for which annotation placement may fail, but the entropy of that content is not one that occurs in practice).
Is this a test content that you added, or you have a real-life content on which this situation occurs?

There is an issue open for this limitation here Loading... . I know I said in there that I have some algorithm improvements, they’re still not added in the platform, sorry.

Also, there were recent improvements on the technique used for displaying annotations - that I personally do not fully master - all this should be checked again on 13.10, to see if anything has changed.

Enjoy,
Anca

1 Like

Thank you for your explanation.
Yes, you are right this text isn’t a real case situation.
I found this bug when I try to understand why annotation and show/hide macro don’t work on a similar page.
When I put annotation, show hide macro stop work (don’t close/open spoiler) and I don\t know what’s the reason.
May be you may help me with it?

Hi urs19work,

the way that the annotations get displayed on the xwiki page content is based on a replacement of the whole HTML of that content with a new HTML that contains markup for the annotated text (so that they can be highlighted on the screen).
This is done on the fly, without reloading the page.
The show/hide macro very probably relies on some javascript binding some click event listeners on the HTML elements of the page content that needs to be shown / hidden, upon page load. When the HTML is replaced for the purpose of the annotations, the elements on which those listeners were originally added are replaced with other elements (even if visually identical), so the listeners are “lost”. This explains why the showing and hiding on click is lost.
As far as I remember, the annotations javascript is firing an event when it does this replacement, so if you’d need to fix this you’d need to update the show/hide javascript that binds these event listeners to not only do it when the page is loaded but also everytime the content of the page is replaced with annotations HTML.

Enjoy,
Anca

1 Like