@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VSpan> annoToSpanIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } // Since we split spans into multiple ranges at sentence boundaries, we can simply check // if there are multiple ranges for a given span. This is cheaper than checking for // every annotation whether the begin/end offset is in the same sentence. for (Entry<AnnotationFS, VSpan> e : annoToSpanIdx.entrySet()) { if (e.getValue().getRanges().size() > 1) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } }
public void add(VComment aComment) { comments.put(aComment.getVid(), aComment); }
for (VComment vcomment : aVDoc.comments()) { String type; switch (vcomment.getCommentType()) { case ERROR: type = AnnotationComment.ANNOTATION_ERROR; !vcomment.getVid().isSynthetic() && ((fs = selectByAddr(aJCas, vcomment.getVid().getId())) instanceof Sentence) ) { int index = sentences.indexOf(fs) + 1; aResponse.addComment(new SentenceComment(index, type, vcomment.getComment())); new AnnotationComment(vcomment.getVid(), type, vcomment.getComment()));
for (VComment vcomment : aVDoc.comments()) { String type; switch (vcomment.getCommentType()) { case ERROR: type = AnnotationComment.ANNOTATION_ERROR; !vcomment.getVid().isSynthetic() && ((fs = selectByAddr(aJCas, vcomment.getVid().getId())) instanceof Sentence) ) { int index = sentences.indexOf(fs) + 1; aResponse.addComment(new SentenceComment(index, type, vcomment.getComment())); new AnnotationComment(vcomment.getVid(), type, vcomment.getComment()));
@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VSpan> annoToSpanIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } // Since we split spans into multiple ranges at sentence boundaries, we can simply check // if there are multiple ranges for a given span. This is cheaper than checking for // every annotation whether the begin/end offset is in the same sentence. for (Entry<AnnotationFS, VSpan> e : annoToSpanIdx.entrySet()) { if (e.getValue().getRanges().size() > 1) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } }
public void add(VComment aComment) { comments.put(aComment.getVid(), aComment); }
default void renderRequiredFeatureErrors(List<AnnotationFeature> aFeatures, FeatureStructure aFS, VDocument aResponse) { for (AnnotationFeature f : aFeatures) { if (isRequiredFeatureMissing(f, aFS)) { aResponse.add(new VComment(new VID(getAddr(aFS)), VCommentType.ERROR, "Required feature [" + f.getName() + "] not set.")); } } } }
default void renderRequiredFeatureErrors(List<AnnotationFeature> aFeatures, FeatureStructure aFS, VDocument aResponse) { for (AnnotationFeature f : aFeatures) { if (isRequiredFeatureMissing(f, aFS)) { aResponse.add(new VComment(new VID(getAddr(aFS)), VCommentType.ERROR, "Required feature [" + f.getName() + "] not set.")); } } } }
@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VArc> aAnnoToArcIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } try { for (Entry<AnnotationFS, VArc> e : aAnnoToArcIdx.entrySet()) { JCas jcas = e.getKey().getCAS().getJCas(); if (!isBeginInSameSentence(jcas, selectByAddr(jcas, e.getValue().getSource().getId()).getBegin(), selectByAddr(jcas, e.getValue().getTarget().getId()).getBegin())) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } } catch (CASException e) { throw new IllegalStateException("Unable to obtain JCas"); } }
@Override public void onRender(TypeAdapter aAdapter, VDocument aResponse, Map<AnnotationFS, VArc> aAnnoToArcIdx) { if (aAdapter.getLayer().isCrossSentence()) { return; } try { for (Entry<AnnotationFS, VArc> e : aAnnoToArcIdx.entrySet()) { JCas jcas = e.getKey().getCAS().getJCas(); if (!isBeginInSameSentence(jcas, selectByAddr(jcas, e.getValue().getSource().getId()).getBegin(), selectByAddr(jcas, e.getValue().getTarget().getId()).getBegin())) { aResponse.add(new VComment(new VID(e.getKey()), ERROR, "Crossing sentence bounardies is not permitted.")); } } } catch (CASException e) { throw new IllegalStateException("Unable to obtain JCas"); } }
first = false; vdoc.add(new VComment(vid, VCommentType.INFO, ao.getRecommenderName())); if (ao.getConfidence() != -1) { vdoc.add(new VComment(vid, VCommentType.INFO, String.format("Confidence: %.2f", ao.getConfidence()))); vdoc.add(new VComment(vid, VCommentType.INFO, "Description: " + ao.getUiLabel())); vdoc.add(new VComment(vid, VCommentType.INFO, "Hidden: " + ao.getReasonForHiding()));
aResponse.add(new VComment(governorFs, VCommentType.YIELD, cm));
aResponse.add(new VComment(governorFs, VCommentType.YIELD, cm));
@Test public void thatSpanStackingBehaviorOnRenderGeneratesErrors() { neLayer.setAllowStacking(false); jcas.setDocumentText(StringUtils.repeat("a", 10)); new Sentence(jcas, 0, 10).addToIndexes(); NamedEntity ne1 = new NamedEntity(jcas, 3, 8); ne1.addToIndexes(); NamedEntity ne2 = new NamedEntity(jcas, 3, 8); ne2.addToIndexes(); SpanAdapter adapter = new SpanAdapter(featureSupportRegistry, null, neLayer, asList(), asList(new SpanStackingBehavior())); SpanRenderer sut = new SpanRenderer(adapter, featureSupportRegistry, asList(new SpanStackingBehavior())); VDocument vdoc = new VDocument(); sut.render(jcas, asList(), vdoc, 0, jcas.getDocumentText().length()); assertThat(vdoc.comments()) .usingFieldByFieldElementComparator() .containsExactlyInAnyOrder( new VComment(ne1, VCommentType.ERROR, "Stacking is not permitted."), new VComment(ne2, VCommentType.ERROR, "Stacking is not permitted.")); } }
.contains(new VComment(dep, VCommentType.ERROR, "Crossing sentence bounardies is not permitted."));