annotorious / annotorious-v3-extensions

Extensions for Annotorious v3
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Text Layer Overlay can't handle ALTO without ID attributes #1

Closed benwbrum closed 4 months ago

benwbrum commented 8 months ago

We ran into a strange problem working with ALTO files generated by Transkribus -- only the last word in the file was appearing as an annotation. After looking at the relevant code and comparing the Transkribus-generated ALTO with the sample file, we determined that the Text Overlay depends on the presence of an ID attribute in the source ALTO files. If no ID is present, all annotations will have an id of null, so each word parsed from the ALTO one overwrites the previous annotation.

We were able to address this on the server side in FromThePage, so there is no urgency in fixing this from us.

Example file: example_alto.zip

rsimon commented 8 months ago

Yikes. One of those small things that break stuff when you're not expecting them. I added a small fix that will also address this on the client. (It will fill in an ad-hoc UUID if no ID is present.) After the fix, I got the attached sample file to display correctly.

But don't deploy any of this yet. I have a new release of Annotorious coming up (hopefully the one with the final API for v3.0.0...), and there are some mini breaking changes. (One function name relevant for you has changed, and "formatters" are now called, simply "styles".) I'll update the example and let you know once the new release is out. (Might happen later today - or mid next week.)

rsimon commented 8 months ago

Hi @benwbrum,

I got the new release out for Annotorious. (Fingers crossed that those are the last breaking changes!) Either way: I made the necessary tweaks to make everything work with the most recent Annotorious version. As you will see, the changes you need to make on your end are minimal.

The only change is how Annotorious is initialized. Here's how this works now:

var anno = AnnotoriousOSD.createOSDAnnotator(viewer, {
  pointerSelectAction: 'NONE',
  style: {
    fillOpacity: 0,
    strokeOpacity: 0
  }
});

The old version was:

var anno = AnnotoriousOSD.createOSDAnnotator(viewer, {
  pointerSelectAction: 'NONE'
});

anno.setFormatter(function() { 
  return { fillOpacity: 0 };
});

Explanation:

benwbrum commented 4 months ago

I believe that this can be closed.