Search in sources :

Example 1 with CasDiff

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

the class PairwiseCodingAgreementTable method exportAllAgreements.

private IResourceStream exportAllAgreements() {
    return new AbstractResourceStream() {

        private static final long serialVersionUID = 1L;

        @Override
        public InputStream getInputStream() throws ResourceStreamNotFoundException {
            AnnotationFeature feature = getModelObject().getFeature();
            DefaultAgreementTraits traits = getModelObject().getTraits();
            Map<String, List<CAS>> casMap = casMapSupplier.get();
            List<DiffAdapter> adapters = CasDiff.getDiffAdapters(annotationService, asList(feature.getLayer()));
            CasDiff diff = doDiff(adapters, traits.getLinkCompareBehavior(), casMap);
            // AgreementResult agreementResult = AgreementUtils.makeStudy(diff,
            // feature.getLayer().getName(), feature.getName(),
            // pref.excludeIncomplete, casMap);
            // TODO: for the moment, we always include incomplete annotations during this
            // export.
            CodingAgreementResult agreementResult = makeCodingStudy(diff, feature.getLayer().getName(), feature.getName(), false, casMap);
            try {
                return AgreementUtils.generateCsvReport(agreementResult);
            } catch (Exception e) {
                // FIXME Is there some better error handling here?
                LOG.error("Unable to generate report", e);
                throw new ResourceStreamNotFoundException(e);
            }
        }

        @Override
        public void close() throws IOException {
        // Nothing to do
        }
    };
}
Also used : AbstractResourceStream(org.apache.wicket.util.resource.AbstractResourceStream) CasDiff(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff) DefaultAgreementTraits(de.tudarmstadt.ukp.clarin.webanno.agreement.measures.DefaultAgreementTraits) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) DiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter) ResourceStreamNotFoundException(org.apache.wicket.util.resource.ResourceStreamNotFoundException) ResourceStreamNotFoundException(org.apache.wicket.util.resource.ResourceStreamNotFoundException) IOException(java.io.IOException) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 2 with CasDiff

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

the class TwoPairedKappaTest method testTwoUserDiffSpanAnnotation.

@Test
public void testTwoUserDiffSpanAnnotation() throws Exception {
    Map<User, List<SourceDocument>> userDocs = new HashMap<>();
    userDocs.put(user1, asList(document));
    userDocs.put(user2, asList(document));
    Map<User, CAS> userCases = new HashMap<>();
    userCases.put(user1, kappatestCas);
    userCases.put(user2, kappaspandiff);
    Map<SourceDocument, Map<User, CAS>> documentJCases = new HashMap<>();
    documentJCases.put(document, userCases);
    // Check against new impl
    CasDiff diff = doDiff(asList(POS_DIFF_ADAPTER), LINK_TARGET_AS_LABEL, convert(userCases));
    DiffResult result = diff.toResult();
    AgreementResult agreement = getCohenKappaAgreement(diff, POS.class.getName(), "PosValue", convert(userCases));
    // Asserts
    System.out.printf("Agreement: %s%n", agreement.toString());
    result.print(System.out);
    assertEquals(0.86153d, agreement.getAgreement(), 0.00001d);
    assertEquals(9, result.size());
    assertEquals(1, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.AgreementResult) CodingAgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding.CodingAgreementResult) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CasDiff(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) CAS(org.apache.uima.cas.CAS) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with CasDiff

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff 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, CAS> userCases = new HashMap<>();
    userCases.put(user1, kappatestCas);
    userCases.put(user2, kappaspanarcdiff);
    Map<SourceDocument, Map<User, CAS>> documentJCases = new HashMap<>();
    documentJCases.put(document, userCases);
    // Check against new impl
    CasDiff diff = doDiff(asList(DEPENDENCY_DIFF_ADAPTER), LINK_TARGET_AS_LABEL, convert(userCases));
    DiffResult result = diff.toResult();
    CodingAgreementResult agreement = getCohenKappaAgreement(diff, Dependency.class.getName(), "DependencyType", convert(userCases));
    // Asserts
    System.out.printf("Agreement: %s%n", agreement.toString());
    result.print(System.out);
    AgreementUtils.dumpAgreementStudy(System.out, agreement);
    assertEquals(0.86153d, agreement.getAgreement(), 0.00001d);
    assertEquals(9, result.size());
    assertEquals(1, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CasDiff(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) Dependency(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency) CodingAgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding.CodingAgreementResult) CAS(org.apache.uima.cas.CAS) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 4 with CasDiff

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

the class TwoPairedKappaTest method testTwoUserDiffArcAnnotation.

@Test
public void testTwoUserDiffArcAnnotation() throws Exception {
    Map<User, List<SourceDocument>> userDocs = new HashMap<>();
    userDocs.put(user1, asList(document));
    userDocs.put(user2, asList(document));
    Map<User, CAS> userCases = new HashMap<>();
    userCases.put(user1, kappatestCas);
    userCases.put(user2, kappaarcdiff);
    Map<SourceDocument, Map<User, CAS>> documentJCases = new HashMap<>();
    documentJCases.put(document, userCases);
    // Check against new impl
    CasDiff diff = doDiff(asList(DEPENDENCY_DIFF_ADAPTER), LINK_TARGET_AS_LABEL, convert(userCases));
    DiffResult result = diff.toResult();
    AgreementResult agreement = getCohenKappaAgreement(diff, Dependency.class.getName(), "DependencyType", convert(userCases));
    // Asserts
    System.out.printf("Agreement: %s%n", agreement.toString());
    result.print(System.out);
    assertEquals(0.86153d, agreement.getAgreement(), 0.00001d);
    assertEquals(9, result.size());
    assertEquals(1, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.AgreementResult) CodingAgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding.CodingAgreementResult) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CasDiff(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) Dependency(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency) CAS(org.apache.uima.cas.CAS) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 5 with CasDiff

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

the class TwoPairedKappaTest method testTwoUserSameAnnotation.

@Test
public void testTwoUserSameAnnotation() throws Exception {
    Map<User, List<SourceDocument>> userDocs = new HashMap<>();
    userDocs.put(user1, asList(document));
    userDocs.put(user2, asList(document));
    Map<User, CAS> userCases = new HashMap<>();
    userCases.put(user1, kappatestCas);
    userCases.put(user2, kappatestCas);
    Map<SourceDocument, Map<User, CAS>> documentJCases = new HashMap<>();
    documentJCases.put(document, userCases);
    // Check against new impl
    CasDiff diff = doDiff(asList(POS_DIFF_ADAPTER), LINK_TARGET_AS_LABEL, convert(userCases));
    DiffResult result = diff.toResult();
    AgreementResult agreement = getCohenKappaAgreement(diff, POS.class.getName(), "PosValue", convert(userCases));
    // Asserts
    System.out.printf("Agreement: %s%n", agreement.toString());
    result.print(System.out);
    assertEquals(1.0d, agreement.getAgreement(), 0.000001);
    assertEquals(9, result.size());
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : AgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.AgreementResult) CodingAgreementResult(de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding.CodingAgreementResult) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CasDiff(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) CAS(org.apache.uima.cas.CAS) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

CasDiff (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff)10 CodingAgreementResult (de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding.CodingAgreementResult)9 Arrays.asList (java.util.Arrays.asList)7 List (java.util.List)7 Map (java.util.Map)6 CAS (org.apache.uima.cas.CAS)6 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult)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 LinkedHashMap (java.util.LinkedHashMap)5 AgreementResult (de.tudarmstadt.ukp.clarin.webanno.agreement.AgreementResult)4 DiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.api.DiffAdapter)4 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)4 Test (org.junit.Test)4 DefaultAgreementTraits (de.tudarmstadt.ukp.clarin.webanno.agreement.measures.DefaultAgreementTraits)3 Dependency (de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency)3 IAgreementMeasure (org.dkpro.statistics.agreement.IAgreementMeasure)3 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)2 IOException (java.io.IOException)2