@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.")); } } }
@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.")); } } }
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."));
@Test public void thatSpanCrossSentenceBehaviorOnRenderGeneratesErrors() { neLayer.setCrossSentence(false); jcas.setDocumentText(StringUtils.repeat("a", 20)); new Sentence(jcas, 0, 10).addToIndexes(); new Sentence(jcas, 10, 20).addToIndexes(); NamedEntity ne = new NamedEntity(jcas, 5, 15); ne.addToIndexes(); SpanAdapter adapter = new SpanAdapter(featureSupportRegistry, null, neLayer, asList(), asList(new SpanCrossSentenceBehavior())); SpanRenderer sut = new SpanRenderer(adapter, featureSupportRegistry, asList(new SpanCrossSentenceBehavior())); VDocument vdoc = new VDocument(); sut.render(jcas, asList(), vdoc, 0, jcas.getDocumentText().length()); assertThat(vdoc.comments()) .usingFieldByFieldElementComparator() .containsExactlyInAnyOrder(new VComment(ne, VCommentType.ERROR, "Crossing sentence bounardies is not permitted.")); }