nilsreiter / CorefAnnotator

Annotation tool for coreference
Apache License 2.0
32 stars 6 forks source link

Fix #381 #384

Closed bkis closed 2 years ago

bkis commented 2 years ago

This PR (mainly) fixes #381

...which describes a bug in deleting a single mention surface (a runtime exception was thrown, therefore the subsequent code for removing the visual representation of the surface from the UI was not executed). Also, some improvements of the UI's representation of the selected items inside the popup menus was made (see below).

381

The error was quite simple: In EntityTreeModel's entityEvent() method, incoming entity events are matched and executed. In case of a Remove event for a single mention surface (of a composite mention), the existing code tried to handle the event's targets as full entity nodes. There was a null-check, but one line accessing the CATreeNode reference (which is null in case of a single surface) was just outside the respective conditional:

CATreeNode etn = fsMap.get(event.getArgument(i));
if (etn != null) {
    etn.removeAllChildren();
    removeNodeFromParent(etn);
}
fsMap.remove(event.getArgument(i));
etn.modify(); // <--  :(

The functionality of this line doesn't depend on the line before. So moving it into the conditional was a safe operation. Deleting a single mention surface now works as expected.

Further improvements in the context of the above bug

As mentioned in the comments to #381, the labeling of mentions, surfaces and entities that are (or aren't) target of an in-text operation via the right-click popup menu were a little misleading. I tried to improve this situation by making the following changes:

As these "cosmetical" improvements don't play a direct role in the bug mentioned in #381, I am very happy to remove them from this PR if they're not wanted (it is possible that I misunderstood those labels 🙄).

Preview of the changes

screen_2021-12-13 14-47