Skip to content

Commit

Permalink
Merge pull request #5169 from inception-project/bugfix/5168-Relations…
Browse files Browse the repository at this point in the history
…-and-links-starting-or-ending-beyond-the-current-window-are-not-visible-in-integrated-curation

#5168 - Relations and links starting or ending beyond the current window are not visible in integrated curation
  • Loading branch information
reckart authored Nov 16, 2024
2 parents d871241 + d7a653c commit edbbf94
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package de.tudarmstadt.ukp.inception.annotation.layer.relation;

import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.groupingBy;
import static org.apache.commons.lang3.StringUtils.abbreviate;
Expand Down Expand Up @@ -71,14 +73,16 @@ public class RelationRenderer
{
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

public static final String REL_EXTENSION_ID = "rel";

public static final VID VID_BEFORE = VID.builder() //
.withExtensionId("rel") //
.withExtensionId(REL_EXTENSION_ID) //
.withAnnotationId(0) //
.withExtensionPayload("before") //
.build();

public static final VID VID_AFTER = VID.builder() //
.withExtensionId("rel") //
.withExtensionId(REL_EXTENSION_ID) //
.withAnnotationId(1) //
.withExtensionPayload("after") //
.build();
Expand Down Expand Up @@ -150,8 +154,8 @@ public List<Annotation> selectAnnotationsInWindow(RenderRequest aRequest, int aW
var targetFs = getTargetFs(rel);

if (sourceFs instanceof Annotation source && targetFs instanceof Annotation target) {
var relBegin = Math.min(source.getBegin(), target.getBegin());
var relEnd = Math.max(source.getEnd(), target.getEnd());
var relBegin = min(source.getBegin(), target.getBegin());
var relEnd = max(source.getEnd(), target.getEnd());

if (overlapping(relBegin, relEnd, aWindowBegin, aWindowEnd)) {
result.add(rel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static de.tudarmstadt.ukp.clarin.webanno.model.LinkMode.NONE;
import static de.tudarmstadt.ukp.inception.annotation.feature.link.LinkFeatureMultiplicityMode.ONE_TARGET_MULTIPLE_ROLES;
import static java.lang.System.currentTimeMillis;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptySet;
import static java.util.stream.Collectors.groupingBy;
Expand Down Expand Up @@ -133,7 +134,7 @@ public static CasDiff doDiff(Iterable<? extends DiffAdapter> aAdapters,
return new CasDiff(0, 0, aAdapters);
}

var startTime = System.currentTimeMillis();
var startTime = currentTimeMillis();

var diff = new CasDiff(aBegin, aEnd, aAdapters);

Expand All @@ -146,7 +147,7 @@ public static CasDiff doDiff(Iterable<? extends DiffAdapter> aAdapters,
}
}

LOG.trace("CASDiff completed in {} ms", System.currentTimeMillis() - startTime);
LOG.trace("CASDiff completed in {} ms", currentTimeMillis() - startTime);

return diff;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_SOURCE;
import static de.tudarmstadt.ukp.inception.support.WebAnnoConst.FEAT_REL_TARGET;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.asList;
import static org.apache.uima.cas.text.AnnotationPredicates.overlapping;

Expand Down Expand Up @@ -88,8 +90,8 @@ public List<Annotation> selectAnnotationsInWindow(CAS aCas, int aWindowBegin, in
var targetFs = getTargetFs(rel);

if (sourceFs instanceof Annotation source && targetFs instanceof Annotation target) {
var relBegin = Math.min(source.getBegin(), target.getBegin());
var relEnd = Math.max(source.getEnd(), target.getEnd());
var relBegin = min(source.getBegin(), target.getBegin());
var relEnd = max(source.getEnd(), target.getEnd());

if (overlapping(relBegin, relEnd, aWindowBegin, aWindowEnd)) {
result.add(rel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.doDiff;
import static de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.getDiffAdapters;
import static de.tudarmstadt.ukp.clarin.webanno.model.Mode.ANNOTATION;
import static de.tudarmstadt.ukp.inception.annotation.layer.relation.RelationRenderer.REL_EXTENSION_ID;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toMap;
Expand Down Expand Up @@ -347,6 +348,10 @@ private void resolveArcEndpoints(String targetUser, DiffResult diff, boolean sho
private VID resolveVisibleLinkHost(String aTargetUser, DiffResult aDiff, Configuration aCfg,
VID aVid, boolean showAll)
{
if (REL_EXTENSION_ID.equals(aVid.getExtensionId())) {
return aVid;
}

var representativeCasGroupId = aCfg.getRepresentativeCasGroupId();

if (showAll) {
Expand Down Expand Up @@ -388,6 +393,10 @@ private VID resolveVisibleLinkHost(String aTargetUser, DiffResult aDiff, Configu
private VID resolveVisibleEndpoint(String aTargetUser, DiffResult aDiff, Configuration aCfg,
VID aVid, boolean showAll)
{
if (REL_EXTENSION_ID.equals(aVid.getExtensionId())) {
return aVid;
}

var sourceConfiguration = aDiff.findConfiguration(aCfg.getRepresentativeCasGroupId(),
new AID(aVid));

Expand Down

0 comments on commit edbbf94

Please sign in to comment.