How to store dynamic references to parts of a text

Posted by Antoine L on Stack Overflow See other posts from Stack Overflow or by Antoine L
Published on 2010-03-13T09:25:18Z Indexed on 2010/03/13 9:35 UTC
Read the original article Hit count: 314

Filed under:
|
|
|

In fact, my question concerns an algorithm. I need to be able to attach annotations to certain parts of a text, like a word or a group of words. The first thing that came to me to do so is to store the position of this part (indexes) in the text.

For instance, in the text 'The quick brown fox jumps over the lazy dog', I'd like to attach an annotation to 'quick brown fox', so the indexes of the annotation would be 4 - 14.

But since the text is editable (other annotations could provoke a modification from text's author), the annoted part is likely to move (the indexes could change). In fact, I don't know how to update the indexes of the annoted part.

What if the text becomes 'Everyday, the quick brown fox jumps over the lazy dog' ?

I guess I have to watch every change of the text in the front-end application ?

The front-end part of the application will be HTML with Javascript. I will be using PHP to develop the back-end part and every text and annotation will be stored in a database.

© Stack Overflow or respective owner

Related posts about database

Related posts about text