use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult in project webanno by webanno.
the class MergeCasTest method simpleSpanDiffWithLabelStackingTest.
@Test
public void simpleSpanDiffWithLabelStackingTest() throws Exception {
Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentenceNEstacked.tsv", "mergecas/simplespan/1sentenceNEstacked.tsv");
List<String> entryTypes = asList(NamedEntity.class.getName());
List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.NER);
addRandomMergeCas(casByUser);
DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
casByUser = new HashMap<>();
JCas actual = DiffUtils.readWebAnnoTSV("mergecas/simplespan/1sentenceNEempty.tsv", null);
casByUser.put("actual", asList(actual));
casByUser.put("merge", asList(mergeCas));
result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
assertEquals(0, result.getDifferingConfigurationSets().size());
assertEquals(0, result.getIncompleteConfigurationSets().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult in project webanno by webanno.
the class MergeCasTest method multiLinkWithRoleTargetDifferenceTest.
@Test
public void multiLinkWithRoleTargetDifferenceTest() throws Exception {
JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
DiffUtils.makeLinkHostFS(jcasA, 0, 0, DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas jcasB = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
DiffUtils.makeLinkHostFS(jcasB, 0, 0, DiffUtils.makeLinkFS(jcasB, "slot1", 10, 10));
Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(jcasA));
casByUser.put("user2", asList(jcasB));
casByUser.put(CURATION_USER, asList(jcasA));
List<String> entryTypes = asList(DiffUtils.HOST_TYPE);
SpanDiffAdapter adapter = new SpanDiffAdapter(DiffUtils.HOST_TYPE);
adapter.addLinkFeature("links", "role", "target");
List<? extends DiffAdapter> diffAdapters = asList(adapter);
DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
result.print(System.out);
JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
Type hostType = mergeCas.getTypeSystem().getType(DiffUtils.HOST_TYPE);
int numHost = CasUtil.select(mergeCas.getCas(), hostType).size();
assertEquals(1, numHost);
for (FeatureStructure host : CasUtil.select(mergeCas.getCas(), hostType)) {
ArrayFS linkFss = (ArrayFS) WebAnnoCasUtil.getFeatureFS(host, "links");
assertEquals(0, linkFss.toArray().length);
}
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult in project webanno by webanno.
the class MergeCasTest method multiLinkWithRoleLabelDifferenceTest.
@Test
public void multiLinkWithRoleLabelDifferenceTest() throws Exception {
JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
DiffUtils.makeLinkHostFS(jcasA, 0, 0, DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas jcasB = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
DiffUtils.makeLinkHostFS(jcasB, 0, 0, DiffUtils.makeLinkFS(jcasB, "slot2", 0, 0));
Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(jcasA));
casByUser.put("user2", asList(jcasB));
casByUser.put(CURATION_USER, asList(jcasA));
List<String> entryTypes = asList(DiffUtils.HOST_TYPE);
SpanDiffAdapter adapter = new SpanDiffAdapter(DiffUtils.HOST_TYPE);
adapter.addLinkFeature("links", "role", "target");
List<? extends DiffAdapter> diffAdapters = asList(adapter);
DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
result.print(System.out);
JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
Type hostType = mergeCas.getTypeSystem().getType(DiffUtils.HOST_TYPE);
int numHost = CasUtil.select(mergeCas.getCas(), hostType).size();
assertEquals(1, numHost);
for (FeatureStructure host : CasUtil.select(mergeCas.getCas(), hostType)) {
ArrayFS linkFss = (ArrayFS) WebAnnoCasUtil.getFeatureFS(host, "links");
assertEquals(0, linkFss.toArray().length);
}
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult in project webanno by webanno.
the class MergeCasTest method simpleSpanNoDiffMultiFeatureTest.
@Test
public void simpleSpanNoDiffMultiFeatureTest() throws Exception {
TypeSystemDescription customeTypes = DiffUtils.createCustomTypeSystem(SPAN_TYPE, "webanno.custom.Opinion", asList("aspect", "opinion"), null);
Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(customeTypes, "mergecas/spanmultifeature/1sentenceNENoFeature.tsv", "mergecas/spanmultifeature/1sentenceNENoFeature.tsv");
List<String> entryTypes = asList("webanno.custom.Opinion");
SpanDiffAdapter spanAdapter = new SpanDiffAdapter("webanno.custom.Opinion", "aspect", "opinion");
List<SpanDiffAdapter> diffAdapters = asList(spanAdapter);
addRandomMergeCas(casByUser);
DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
casByUser = new HashMap<>();
JCas actual = DiffUtils.readWebAnnoTSV("mergecas/spanmultifeature/1sentenceNENoFeature.tsv", customeTypes);
casByUser.put("actual", asList(actual));
casByUser.put("merge", asList(mergeCas));
result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
assertEquals(0, result.getDifferingConfigurationSets().size());
assertEquals(0, result.getIncompleteConfigurationSets().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult in project webanno by webanno.
the class TwoPairedKappaTest method testTwoUserDiffArcAndSpanAnnotation.
@Test
public void testTwoUserDiffArcAndSpanAnnotation() throws Exception {
Map<User, List<SourceDocument>> userDocs = new HashMap<>();
userDocs.put(user1, asList(document));
userDocs.put(user2, asList(document));
Map<User, JCas> userCases = new HashMap<>();
userCases.put(user1, kappatestCas.getJCas());
userCases.put(user2, kappaspanarcdiff.getJCas());
Map<SourceDocument, Map<User, JCas>> documentJCases = new HashMap<>();
documentJCases.put(document, userCases);
// Check against new impl
DiffResult diff = CasDiff2.doDiff(Dependency.class, new ArcDiffAdapter(Dependency.class, "Dependent", "Governor", "DependencyType"), LinkCompareBehavior.LINK_TARGET_AS_LABEL, convert(userCases));
AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(diff, Dependency.class.getName(), "DependencyType", convert(userCases));
// Asserts
System.out.printf("Agreement: %s%n", agreement.toString());
diff.print(System.out);
AgreementUtils.dumpAgreementStudy(System.out, agreement);
assertEquals(0.86153d, agreement.getAgreement(), 0.00001d);
assertEquals(9, diff.size());
assertEquals(1, diff.getDifferingConfigurationSets().size());
assertEquals(0, diff.getIncompleteConfigurationSets().size());
}
Aggregations