Search in sources :

Example 1 with SpanDiffAdapter

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter in project webanno by webanno.

the class CasMergeTest method multiLinkMultiHostTest.

@Test
public void multiLinkMultiHostTest() throws Exception {
    // Creating two span stacked annotations. This should cause the data not to be merged.
    JCas jcasA = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
    makeLinkHostFS(jcasA, 0, 0, makeLinkFS(jcasA, "slot1", 0, 0));
    makeLinkHostFS(jcasA, 0, 0, makeLinkFS(jcasA, "slot1", 0, 0));
    JCas jcasB = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
    makeLinkHostFS(jcasB, 0, 0, makeLinkFS(jcasB, "slot1", 0, 0));
    Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(jcasA.getCas()));
    casByUser.put("user2", asList(jcasB.getCas()));
    CAS curatorCas = createJCas(createMultiLinkWithRoleTestTypeSystem("f1")).getCas();
    curatorCas.setDocumentText(casByUser.values().stream().flatMap(Collection::stream).findFirst().get().getDocumentText());
    SpanDiffAdapter adapter = new SpanDiffAdapter(HOST_TYPE);
    adapter.addLinkFeature("links", "role", "target");
    DiffResult result = doDiff(asList(adapter), LINK_TARGET_AS_LABEL, casByUser).toResult();
    // result.print(System.out);
    sut.reMergeCas(result, document, null, curatorCas, getSingleCasByUser(casByUser));
    assertThat(select(curatorCas, getType(curatorCas, HOST_TYPE))).isEmpty();
}
Also used : CAS(org.apache.uima.cas.CAS) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) Collection(java.util.Collection) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 2 with SpanDiffAdapter

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter in project webanno by webanno.

the class CasDiffTest method spanLabelLabelTest.

@Test
public void spanLabelLabelTest() throws Exception {
    Map<String, List<CAS>> casByUser = load("casdiff/spanLabel/user1.conll", "casdiff/spanLabel/user2.conll");
    List<? extends DiffAdapter> diffAdapters = asList(new SpanDiffAdapter(POS.class.getName(), "PosValue"));
    CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
    DiffResult result = diff.toResult();
    // result.print(System.out);
    assertEquals(26, result.size());
    assertEquals(1, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
// Todo: Agreement has moved to separate project - should create agreement test there
// CodingAgreementResult agreement = getCohenKappaAgreement(diff, entryTypes.get(0),
// "PosValue", casByUser);
// assertEquals(0.958730d, agreement.getAgreement(), 0.000001d);
// assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
Also used : SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) Test(org.junit.Test)

Example 3 with SpanDiffAdapter

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter in project webanno by webanno.

the class CasDiffTest method multiLinkWithRoleMultiTargetDifferenceTest2.

@Test
public void multiLinkWithRoleMultiTargetDifferenceTest2() throws Exception {
    JCas jcasA = JCasFactory.createJCas(createMultiLinkWithRoleTestTypeSystem());
    makeLinkHostFS(jcasA, 0, 0, makeLinkFS(jcasA, "slot1", 0, 0), makeLinkFS(jcasA, "slot1", 10, 10));
    JCas jcasB = JCasFactory.createJCas(createMultiLinkWithRoleTestTypeSystem());
    makeLinkHostFS(jcasB, 0, 0, makeLinkFS(jcasB, "slot2", 10, 10));
    Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(jcasA.getCas()));
    casByUser.put("user2", asList(jcasB.getCas()));
    SpanDiffAdapter adapter = new SpanDiffAdapter(HOST_TYPE);
    adapter.addLinkFeature("links", "role", "target");
    List<? extends DiffAdapter> diffAdapters = asList(adapter);
    DiffResult diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();
    // diff.print(System.out);
    assertEquals(3, diff.size());
    assertEquals(1, diff.getDifferingConfigurationSets().size());
    assertEquals(2, diff.getIncompleteConfigurationSets().size());
// // Check against new impl
// AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(diff, HOST_TYPE,
// "links",
// casByUser);
// 
// // Asserts
// System.out.printf("Agreement: %s%n", agreement.toString());
// AgreementUtils.dumpAgreementStudy(System.out, agreement);
// 
// assertEquals(0.0, agreement.getAgreement(), 0.00001d);
}
Also used : SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 4 with SpanDiffAdapter

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter in project webanno by webanno.

the class CasDiffTest method multipleEmptyCasWithMissingOnesTest.

@Test
public void multipleEmptyCasWithMissingOnesTest() throws Exception {
    String text = "";
    CAS user1Cas1 = null;
    CAS user1Cas2 = null;
    CAS user1Cas3 = JCasFactory.createJCas().getCas();
    user1Cas3.setDocumentText(text);
    CAS user1Cas4 = JCasFactory.createJCas().getCas();
    user1Cas4.setDocumentText(text);
    CAS user2Cas1 = JCasFactory.createJCas().getCas();
    user2Cas1.setDocumentText(text);
    CAS user2Cas2 = null;
    CAS user2Cas3 = null;
    CAS user2Cas4 = JCasFactory.createJCas().getCas();
    user2Cas4.setDocumentText(text);
    Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(user1Cas1, user1Cas2, user1Cas3, user1Cas4));
    casByUser.put("user2", asList(user2Cas1, user2Cas2, user2Cas3, user2Cas4));
    List<SpanDiffAdapter> diffAdapters = asList(new SpanDiffAdapter(Lemma.class.getName()));
    CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
    DiffResult result = diff.toResult();
    // result.print(System.out);
    assertEquals(0, result.size());
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
// Todo: Agreement has moved to separate project - should create agreement test there
// CodingAgreementResult agreement = AgreementUtils.getCohenKappaAgreement(diff,
// entryTypes.get(0), "value", casByUser);
// assertEquals(Double.NaN, agreement.getAgreement(), 0.000001d);
// assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
Also used : CAS(org.apache.uima.cas.CAS) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 5 with SpanDiffAdapter

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter in project webanno by webanno.

the class CasDiffTest method someDifferencesTest.

@Test
public void someDifferencesTest() throws Exception {
    Map<String, List<CAS>> casByUser = load("casdiff/someDifferences/user1.conll", "casdiff/someDifferences/user2.conll");
    List<SpanDiffAdapter> diffAdapters = asList(POS_DIFF_ADAPTER);
    CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
    DiffResult result = diff.toResult();
    // result.print(System.out);
    assertEquals(26, result.size());
    assertEquals(4, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
// Todo: Agreement has moved to separate project - should create agreement test there
// CodingAgreementResult agreement = getCohenKappaAgreement(diff, entryTypes.get(0),
// "PosValue", casByUser);
// assertEquals(0.836477987d, agreement.getAgreement(), 0.000001d);
// assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
Also used : SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) Test(org.junit.Test)

Aggregations

SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter)16 ArrayList (java.util.ArrayList)14 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult)13 Arrays.asList (java.util.Arrays.asList)13 List (java.util.List)13 Test (org.junit.Test)13 LinkedHashMap (java.util.LinkedHashMap)8 JCasFactory.createJCas (org.apache.uima.fit.factory.JCasFactory.createJCas)6 JCas (org.apache.uima.jcas.JCas)6 CAS (org.apache.uima.cas.CAS)3 DiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter)2 RelationDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.relation.RelationDiffAdapter)2 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)2 RelationAdapter (de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.RelationAdapter)1 BooleanFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.BooleanFeatureSupport)1 FeatureSupportRegistryImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.FeatureSupportRegistryImpl)1 NumberFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.NumberFeatureSupport)1 SlotFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.SlotFeatureSupport)1 StringFeatureSupport (de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.StringFeatureSupport)1