Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to modify annotation offset? #12

Open
10zinten opened this issue Jul 26, 2024 · 1 comment
Open

How to modify annotation offset? #12

10zinten opened this issue Jul 26, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@10zinten
Copy link

Hey, guys!

I am one of the developer working on adopting STAM in OpenPecha. Currently, I am trying to implement this and I am facing an issue with modifying offset of an annotation.

Current output:

...
>>>str(annotation.offset())
'3:5'
>>>annotation.offset().shift(1)
>>>str(annotation.offset())
'3:5'

As you can see the offset remain same even after performing shift.

Expected output:

...
>>>str(annotation.offset())
'3:5'
>>>annotation.offset().shift(1)
>>>str(annotation.offset())
'4:6'

How to achieve this in STAM?

@10zinten 10zinten changed the title How to update annotation offset? How to modify annotation offset? Jul 26, 2024
@proycon
Copy link
Contributor

proycon commented Aug 1, 2024

I understand the confusion.

Most of the methods in the STAM python binding return either immutable copies or immutable references to the original data. So when you do annotation.offset() you get an offset instance that is a copy. Changing that copy by calling shift does not update the original. The same goes for most other methods that return data.

In STAM, annotations are largely considered immutable once made. Read this section for the rationale behind this. The canonical way to modify an annotation is to delete an annotation, and to create a new one. This does have repercussions for any annotations loaded in the store that depend on the removed annotation (they would automatically be removed along with it).

Now I understand that in your use case you want to have some flexibility to alter annotations and still have other annotations refer to it. You're decoupling the alignments from the annotations that refer to the text, by storing them in separate stores, so that will give you this option. Updating an annotation would then boil down to:

  • removing the annotation (but make sure the alignments are not loaded at the same time!)
  • re-adding a modified version of the annotation (with the new offset) but with the same public identifier. That way the stand-off alignments remain valid when loaded, even though the underlying annotation changed.

This will also depend on resolution of annotation/stam#29 which I'll be working on soon.

@proycon proycon self-assigned this Aug 1, 2024
@proycon proycon added the question Further information is requested label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants