Search in sources :

Example 36 with DiffResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.

the class CasDiffTest method multiLinkWithRoleTargetDifferenceTest.

@Test
public void multiLinkWithRoleTargetDifferenceTest() throws Exception {
    JCas jcasA = createJCas(createMultiLinkWithRoleTestTypeSystem());
    makeLinkHostFS(jcasA, 0, 0, makeLinkFS(jcasA, "slot1", 0, 0));
    JCas jcasB = createJCas(createMultiLinkWithRoleTestTypeSystem());
    makeLinkHostFS(jcasB, 0, 0, makeLinkFS(jcasB, "slot1", 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);
    CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
    DiffResult result = diff.toResult();
    // result.print(System.out);
    assertEquals(2, 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, 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 37 with DiffResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.

the class CasDiffTest method singleEmptyCasTest.

@Test
public void singleEmptyCasTest() throws Exception {
    String text = "";
    CAS user1Cas = JCasFactory.createJCas().getCas();
    user1Cas.setDocumentText(text);
    Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(user1Cas));
    List<SpanDiffAdapter> diffAdapters = asList(new SpanDiffAdapter(Token.class.getName()));
    DiffResult result = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser).toResult();
    // result.print(System.out);
    assertEquals(0, result.size());
    assertEquals(0, result.getDifferingConfigurationSets().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 38 with DiffResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.

the class CasDiffTest method noDifferencesPosTest.

@Test
public void noDifferencesPosTest() throws Exception {
    Map<String, List<CAS>> casByUser = load("casdiff/noDifferences/data.conll", "casdiff/noDifferences/data.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(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), "PosValue", casByUser);
// assertEquals(1.0d, 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 39 with DiffResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.

the class CasDiffTest method multiLinkWithRoleMultiTargetDifferenceTest.

@Test
public void multiLinkWithRoleMultiTargetDifferenceTest() 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, "slot1", 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(2, diff.size());
    assertEquals(1, diff.getDifferingConfigurationSets().size());
    assertEquals(0, 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 40 with DiffResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.

the class CasMergeTest method multiLinkMultiSpanRoleDiffTest.

@Test
public void multiLinkMultiSpanRoleDiffTest() throws Exception {
    JCas jcasA = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
    Type type = jcasA.getTypeSystem().getType(HOST_TYPE);
    Feature feature = type.getFeatureByBaseName("f1");
    makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", makeLinkFS(jcasA, "slot1", 0, 0));
    JCas jcasB = createJCas(createMultiLinkWithRoleTestTypeSystem("f1"));
    makeLinkHostMultiSPanFeatureFS(jcasB, 0, 0, feature, "A", 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.getTypeSystem().getType(HOST_TYPE);
    assertThat(select(curatorCas.getCas(), hostType)).hasSize(1);
}
Also used : Type(org.apache.uima.cas.Type) CasUtil.getType(org.apache.uima.fit.util.CasUtil.getType) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) 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) FSUtil.getFeature(org.apache.uima.fit.util.FSUtil.getFeature) Feature(org.apache.uima.cas.Feature) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult)44 Test (org.junit.Test)39 Arrays.asList (java.util.Arrays.asList)34 List (java.util.List)34 ArrayList (java.util.ArrayList)31 LinkedHashMap (java.util.LinkedHashMap)25 CAS (org.apache.uima.cas.CAS)16 JCas (org.apache.uima.jcas.JCas)16 JCasFactory.createJCas (org.apache.uima.fit.factory.JCasFactory.createJCas)15 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter)14 CodingAgreementResult (de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding.CodingAgreementResult)11 HashMap (java.util.HashMap)11 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)9 Map (java.util.Map)9 Collection (java.util.Collection)8 Type (org.apache.uima.cas.Type)8 CasUtil.getType (org.apache.uima.fit.util.CasUtil.getType)7 CasDiff (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff)5 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)5 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)5