Search in sources :

Example 6 with AgreementResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult in project webanno by webanno.

the class CasDiff2Test method spanLabelLabelTest.

@Test
public void spanLabelLabelTest() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.load("casdiff/spanLabel/user1.conll", "casdiff/spanLabel/user2.conll");
    List<String> entryTypes = asList(POS.class.getName());
    List<? extends DiffAdapter> diffAdapters = asList(new SpanDiffAdapter(POS.class.getName(), "PosValue"));
    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    result.print(System.out);
    assertEquals(26, result.size());
    assertEquals(1, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
    AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(result, entryTypes.get(0), "PosValue", casByUser);
    assertEquals(0.958730d, agreement.getAgreement(), 0.000001d);
    assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) Test(org.junit.Test)

Example 7 with AgreementResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult in project webanno by webanno.

the class CasDiff2Test method multiLinkWithRoleLabelDifferenceTest2.

@Test
public void multiLinkWithRoleLabelDifferenceTest2() 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));
    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 diff = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_ROLE_AS_LABEL, casByUser);
    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, DiffUtils.HOST_TYPE, "links", casByUser);
    // Asserts
    System.out.printf("Agreement: %s%n", agreement.toString());
    AgreementUtils.dumpAgreementStudy(System.out, agreement);
    assertEquals(0.0d, agreement.getAgreement(), 0.00001d);
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 8 with AgreementResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult in project webanno by webanno.

the class CasDiff2Test method multiLinkWithRoleNoDifferenceTest.

@Test
public void multiLinkWithRoleNoDifferenceTest() throws Exception {
    JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
    DiffUtils.makeLinkHostFS(jcasA, 0, 0, DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
    DiffUtils.makeLinkHostFS(jcasA, 10, 10, DiffUtils.makeLinkFS(jcasA, "slot1", 10, 10));
    JCas jcasB = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
    DiffUtils.makeLinkHostFS(jcasB, 0, 0, DiffUtils.makeLinkFS(jcasB, "slot1", 0, 0));
    DiffUtils.makeLinkHostFS(jcasB, 10, 10, DiffUtils.makeLinkFS(jcasB, "slot1", 10, 10));
    Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(jcasA));
    casByUser.put("user2", asList(jcasB));
    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 diff = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    diff.print(System.out);
    assertEquals(4, diff.size());
    assertEquals(0, diff.getDifferingConfigurationSets().size());
    assertEquals(0, diff.getIncompleteConfigurationSets().size());
    // Check against new impl
    AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(diff, DiffUtils.HOST_TYPE, "links", casByUser);
    // Asserts
    System.out.printf("Agreement: %s%n", agreement.toString());
    AgreementUtils.dumpAgreementStudy(System.out, agreement);
    assertEquals(1.0d, agreement.getAgreement(), 0.00001d);
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 9 with AgreementResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult in project webanno by webanno.

the class CasDiff2Test method singleNoDifferencesWithAdditionalCas1Test.

@Test
public void singleNoDifferencesWithAdditionalCas1Test() throws Exception {
    JCas user1 = JCasFactory.createJCas();
    user1.setDocumentText("test");
    JCas user2 = JCasFactory.createJCas();
    user2.setDocumentText("test");
    JCas user3 = JCasFactory.createJCas();
    user3.setDocumentText("test");
    POS pos3 = new POS(user3, 0, 4);
    pos3.setPosValue("test");
    pos3.addToIndexes();
    Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(user1));
    casByUser.put("user2", asList(user2));
    casByUser.put("user3", asList(user3));
    List<String> entryTypes = asList(POS.class.getName());
    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);
    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    result.print(System.out);
    casByUser.remove("user3");
    AgreementResult agreement = AgreementUtils.getAgreement(ConcreteAgreementMeasure.KRIPPENDORFF_ALPHA_NOMINAL_AGREEMENT, false, result, entryTypes.get(0), "PosValue", casByUser);
    assertEquals(1, agreement.getTotalSetCount());
    assertEquals(1, agreement.getIrrelevantSets().size());
    assertEquals(0, agreement.getRelevantSetCount());
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 10 with AgreementResult

use of de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult 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());
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) ArcDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) JCas(org.apache.uima.jcas.JCas) Dependency(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

AgreementResult (de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult)25 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)24 Arrays.asList (java.util.Arrays.asList)24 List (java.util.List)24 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)19 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter)16 LinkedHashMap (java.util.LinkedHashMap)15 JCas (org.apache.uima.jcas.JCas)15 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)11 Dependency (de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency)7 ArcDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter)5 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)5 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Lemma (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma)2 AJAXDownload (de.tudarmstadt.ukp.clarin.webanno.support.AJAXDownload)1 NamedEntity (de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity)1 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)1