use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class KrippendorffAlphaNominalAgreementMeasureTest method multiLinkWithRoleLabelDifference.
@Test
public void multiLinkWithRoleLabelDifference() throws Exception {
PairwiseAnnotationResult<CodingAgreementResult> agreement = multiLinkWithRoleLabelDifferenceTest(sut);
CodingAgreementResult result = agreement.getStudy("user1", "user2");
DiffResult diff = result.getDiff();
diff.print(System.out);
assertEquals(3, diff.size());
assertEquals(0, diff.getDifferingConfigurationSets().size());
assertEquals(2, diff.getIncompleteConfigurationSets().size());
assertEquals(NaN, result.getAgreement(), 0.00001d);
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class SuggestionBuilder method createCurationCas.
/**
* For the first time a curation page is opened, create a MergeCas that contains only agreeing
* annotations Using the CAS of the curator user.
*
* @param aState
* the annotator state
* @param aRandomAnnotationDocument
* an annotation document.
* @param aCasses
* the CASes
* @param aAnnotationLayers
* the layers.
* @return the CAS.
* @throws IOException
* if an I/O error occurs.
*/
private CAS createCurationCas(AnnotatorState aState, AnnotationDocument aRandomAnnotationDocument, Map<String, CAS> aCasses, List<AnnotationLayer> aAnnotationLayers, boolean aMergeIncompleteAnnotations) throws IOException, UIMAException, AnnotationException {
Validate.notNull(aState, "State must be specified");
Validate.notNull(aRandomAnnotationDocument, "Annotation document must be specified");
// We need a modifiable copy of some annotation document which we can use to initialize
// the curation CAS. This is an exceptional case where BYPASS is the correct choice
CAS mergeCas = documentService.readAnnotationCas(aRandomAnnotationDocument, UNMANAGED_ACCESS);
List<DiffAdapter> adapters = getDiffAdapters(schemaService, aState.getAnnotationLayers());
DiffResult diff;
try (StopWatch watch = new StopWatch(log, "CasDiff")) {
diff = doDiffSingle(adapters, LINK_ROLE_AS_LABEL, aCasses, 0, mergeCas.getDocumentText().length()).toResult();
}
try (StopWatch watch = new StopWatch(log, "CasMerge")) {
CasMerge casMerge = new CasMerge(schemaService);
casMerge.setMergeIncompleteAnnotations(aMergeIncompleteAnnotations);
casMerge.reMergeCas(diff, aState.getDocument(), aState.getUser().getUsername(), mergeCas, aCasses);
}
curationDocumentService.writeCurationCas(mergeCas, aRandomAnnotationDocument.getDocument(), false);
return mergeCas;
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasMergeTest method copyLinkToEmptyTest.
@Test
public void copyLinkToEmptyTest() throws Exception {
JCas mergeCas = createJCas(CurationTestUtils.createMultiLinkWithRoleTestTypeSystem("f1"));
Type type = mergeCas.getTypeSystem().getType(CurationTestUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
AnnotationFS mergeFs = makeLinkHostMultiSPanFeatureFS(mergeCas, 0, 0, feature, "A");
FeatureStructure copyFS = CurationTestUtils.makeLinkFS(mergeCas, "slot1", 0, 0);
List<FeatureStructure> linkFs = new ArrayList<>();
linkFs.add(copyFS);
WebAnnoCasUtil.setLinkFeatureValue(mergeFs, type.getFeatureByBaseName("links"), linkFs);
JCas jcasA = createJCas(CurationTestUtils.createMultiLinkWithRoleTestTypeSystem("f1"));
makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", makeLinkFS(jcasA, "slot1", 0, 0));
Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(mergeCas.getCas()));
casByUser.put("user2", asList(jcasA.getCas()));
DiffResult diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();
assertEquals(0, diff.getDifferingConfigurationSets().size());
assertEquals(0, diff.getIncompleteConfigurationSets().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasMergeTest method multiLinkWithRoleNoDifferenceTest.
@Test
public void multiLinkWithRoleNoDifferenceTest() throws Exception {
JCas jcasA = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
makeLinkHostFS(jcasA, 0, 0, makeLinkFS(jcasA, "slot1", 0, 0));
makeLinkHostFS(jcasA, 10, 10, makeLinkFS(jcasA, "slot1", 10, 10));
JCas jcasB = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
makeLinkHostFS(jcasB, 0, 0, makeLinkFS(jcasB, "slot1", 0, 0));
makeLinkHostFS(jcasB, 10, 10, makeLinkFS(jcasB, "slot1", 10, 10));
Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(jcasA.getCas()));
casByUser.put("user2", asList(jcasB.getCas()));
JCas curatorCas = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
curatorCas.setDocumentText(casByUser.values().stream().flatMap(Collection::stream).findFirst().get().getDocumentText());
DiffResult result = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();
// result.print(System.out);
sut.reMergeCas(result, document, null, curatorCas.getCas(), getSingleCasByUser(casByUser));
casByUser = new HashMap<>();
casByUser.put("actual", asList(jcasA.getCas()));
casByUser.put("merge", asList(curatorCas.getCas()));
result = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();
assertEquals(0, result.getDifferingConfigurationSets().size());
assertEquals(0, result.getIncompleteConfigurationSets().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasMergeTest method multiLinkWithRoleLabelDifferenceTest.
@Test
public void multiLinkWithRoleLabelDifferenceTest() throws Exception {
JCas jcasA = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
makeLinkHostFS(jcasA, 0, 0, makeLinkFS(jcasA, "slot1", 0, 0));
JCas jcasB = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
makeLinkHostFS(jcasB, 0, 0, makeLinkFS(jcasB, "slot2", 0, 0));
Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(jcasA.getCas()));
casByUser.put("user2", asList(jcasB.getCas()));
JCas curatorCas = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
curatorCas.setDocumentText(casByUser.values().stream().flatMap(Collection::stream).findFirst().get().getDocumentText());
DiffResult result = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();
// result.print(System.out);
sut.reMergeCas(result, document, null, curatorCas.getCas(), getSingleCasByUser(casByUser));
Type hostType = curatorCas.getCas().getTypeSystem().getType(HOST_TYPE);
FeatureSupport slotSupport = featureSupportRegistry.getFeatureSupport(slotFeature);
assertThat(select(curatorCas.getCas(), hostType)).hasSize(1);
assertThat(select(curatorCas.getCas(), hostType).stream().map(host -> (List) slotSupport.getFeatureValue(slotFeature, host))).allMatch(Collection::isEmpty);
}
Aggregations