Skip to content

Commit

Permalink
#4495 - Error marker on annotations with required multi-value feature…
Browse files Browse the repository at this point in the history
…s is missing

- Fix displaying validation comments in the brat editor
- Fix validation of required multi-value string/concept features
  • Loading branch information
reckart committed Feb 3, 2024
1 parent 947f1fc commit 33a7652
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,6 @@ export class Visualizer {
this.calculateChunkTextElementMeasure(fragment, text))
}



/**
* measure the text position in pixels
*/
Expand All @@ -1303,8 +1301,7 @@ export class Visualizer {
collapsedSpaces++
}
lastCharSpace = true
}
else {
} else {
lastCharSpace = false
}
}
Expand Down Expand Up @@ -3548,6 +3545,13 @@ export class Visualizer {
fakeSpan.vid = id
fakeSpan.document = { text: this.data.text }
fakeSpan.layer = { id: span.type, name: Util.spanDisplayForm(this.entityTypes, span.type) }
if (span.comment) {
if (span.comment.type === 'AnnotationError') {
fakeSpan.comments = [{ type: 'error', comment: span.comment.text }]
} else {
fakeSpan.comments = [{ type: 'info', comment: span.comment.text }]
}
}
evt.target.dispatchEvent(new AnnotationOverEvent(fakeSpan, evt.originalEvent))
}

Expand Down Expand Up @@ -3713,6 +3717,13 @@ export class Visualizer {
fakeRelation.vid = arcId
const labelText = Util.arcDisplayForm(this.entityTypes, originSpanType, role, this.relationTypes)
fakeRelation.layer = { id: role, name: labelText }
if (commentText) {
if (commentType === 'AnnotationError') {
fakeRelation.comments = [{ type: 'error', comment: commentText }]
} else {
fakeRelation.comments = [{ type: 'info', comment: commentText }]
}
}
evt.target.dispatchEvent(new AnnotationOverEvent(fakeRelation, evt.originalEvent))
}

Expand Down Expand Up @@ -3747,7 +3758,7 @@ export class Visualizer {
fakeSpan.layer = { id: 0, name: Util.spanDisplayForm(this.entityTypes, comment.type) }
evt.target.dispatchEvent(new AnnotationOverEvent(fakeSpan, evt.originalEvent))
}

this.dispatcher.post('displaySentComment', [evt, comment.text, comment.type])
}
}
Expand Down Expand Up @@ -3800,7 +3811,6 @@ export class Visualizer {

if (target.getAttribute('data-arc-role')) {
this.onMouseOutArc(evt)
return
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.uima.cas.CAS.TYPE_NAME_STRING;

import java.util.List;

import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.fit.util.FSUtil;

Expand All @@ -38,6 +41,11 @@ public static boolean isRequiredFeatureMissing(AnnotationFeature aFeature, Featu
return isBlank(FSUtil.getFeature(aFS, aFeature.getName(), String.class));
}

if (CAS.TYPE_NAME_STRING_ARRAY.equals(aFeature.getType())) {
var value = FSUtil.getFeature(aFS, aFeature.getName(), List.class);
return value == null || value.isEmpty();
}

return false;
}
}

0 comments on commit 33a7652

Please sign in to comment.