OpenPecha / Toolkit

🛠 Tools to create, edit and export texts and annotations
https://toolkit.openpecha.org
Apache License 2.0
7 stars 4 forks source link

format of annotation layers #180

Open eroux opened 1 year ago

eroux commented 1 year ago

currently inside a layer annotations are stored in an object:

id: 32256a98594543a8b5a5013af8cab7f9
annotation_type: Pagination
revision: '00001'
annotations:
  81a6c8d478834c8c994189ef50e8865a:
    imgnum: 1
    reference: I1PD1088170001.tif
    span:
      start: 0
      end: 629

which may have some benefits, but I think it has a huge issues: objects are not sorted so if you want to return annotations in order for just a range of characters (which I suspect is a fairly common use case), you have to read all the annotations, sort them by spans, and then filter the results by number of characters. That's a huge performance issue, I suspect this might impact the UI of the editor as well

10zinten commented 1 year ago

@eroux right, but for annotation lookup operation with annotation id, then we need to linear search over all the annotations. Anyway this is much less expensive than sorting and filtering.

sure, I will refactor to store annotations into list with order of span.