Search in sources :

Example 1 with ICodingAnnotationItem

use of de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem in project webanno by webanno.

the class AgreementUtils method configurationSetsWithItemsToCsv.

private static void configurationSetsWithItemsToCsv(CSVPrinter aOut, AgreementResult aAgreement, List<ConfigurationSet> aSets) throws IOException {
    List<String> headers = new ArrayList<>(asList("Type", "Collection", "Document", "Layer", "Feature", "Position"));
    headers.addAll(aAgreement.getCasGroupIds());
    aOut.printRecord(headers);
    int i = 0;
    for (ICodingAnnotationItem item : aAgreement.getStudy().getItems()) {
        Position pos = aSets.get(i).getPosition();
        List<String> values = new ArrayList<>();
        values.add(pos.getClass().getSimpleName());
        values.add(pos.getCollectionId());
        values.add(pos.getDocumentId());
        values.add(pos.getType());
        values.add(aAgreement.getFeature());
        values.add(aSets.get(i).getPosition().toMinimalString());
        for (IAnnotationUnit unit : item.getUnits()) {
            values.add(String.valueOf(unit.getCategory()));
        }
        aOut.printRecord(values);
        i++;
    }
}
Also used : ArcPosition(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcPosition) Position(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Position) IAnnotationUnit(de.tudarmstadt.ukp.dkpro.statistics.agreement.IAnnotationUnit) ArrayList(java.util.ArrayList) ICodingAnnotationItem(de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem)

Example 2 with ICodingAnnotationItem

use of de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem in project webanno by webanno.

the class AgreementUtils method dumpAgreementConfigurationSetsWithItems.

private static void dumpAgreementConfigurationSetsWithItems(PrintStream aOut, AgreementResult aAgreement, List<ConfigurationSet> aSets) {
    int i = 0;
    for (ICodingAnnotationItem item : aAgreement.getStudy().getItems()) {
        StringBuilder sb = new StringBuilder();
        sb.append(aSets.get(i).getPosition());
        for (IAnnotationUnit unit : item.getUnits()) {
            if (sb.length() > 0) {
                sb.append(" \t");
            }
            sb.append(unit.getCategory());
        }
        aOut.println(sb);
        i++;
    }
}
Also used : IAnnotationUnit(de.tudarmstadt.ukp.dkpro.statistics.agreement.IAnnotationUnit) ICodingAnnotationItem(de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem)

Example 3 with ICodingAnnotationItem

use of de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem in project webanno by webanno.

the class AgreementUtils method dumpStudy.

public static void dumpStudy(PrintStream aOut, ICodingAnnotationStudy aStudy) {
    try {
        aOut.printf("Category count: %d%n", aStudy.getCategoryCount());
    } catch (Throwable e) {
        aOut.printf("Category count: %s%n", ExceptionUtils.getRootCauseMessage(e));
    }
    try {
        aOut.printf("Item count: %d%n", aStudy.getItemCount());
    } catch (Throwable e) {
        aOut.printf("Item count: %s%n", ExceptionUtils.getRootCauseMessage(e));
    }
    for (ICodingAnnotationItem item : aStudy.getItems()) {
        StringBuilder sb = new StringBuilder();
        for (IAnnotationUnit unit : item.getUnits()) {
            if (sb.length() > 0) {
                sb.append(" \t");
            }
            sb.append(unit.getCategory());
        }
        aOut.println(sb);
    }
}
Also used : IAnnotationUnit(de.tudarmstadt.ukp.dkpro.statistics.agreement.IAnnotationUnit) ICodingAnnotationItem(de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem)

Example 4 with ICodingAnnotationItem

use of de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem in project webanno by webanno.

the class CasDiff2Test method twoWithoutLabelTest.

@Test
public void twoWithoutLabelTest() throws Exception {
    JCas user1 = JCasFactory.createJCas();
    user1.setDocumentText("test");
    new POS(user1, 0, 1).addToIndexes();
    new POS(user1, 1, 2).addToIndexes();
    POS p1 = new POS(user1, 3, 4);
    p1.setPosValue("A");
    p1.addToIndexes();
    JCas user2 = JCasFactory.createJCas();
    user2.setDocumentText("test");
    new POS(user2, 0, 1).addToIndexes();
    new POS(user2, 2, 3).addToIndexes();
    POS p2 = new POS(user2, 3, 4);
    p2.setPosValue("B");
    p2.addToIndexes();
    Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(user1));
    casByUser.put("user2", asList(user2));
    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);
    AgreementResult agreement = AgreementUtils.getAgreement(ConcreteAgreementMeasure.KRIPPENDORFF_ALPHA_NOMINAL_AGREEMENT, false, result, entryTypes.get(0), "PosValue", casByUser);
    assertEquals(4, agreement.getTotalSetCount());
    assertEquals(0, agreement.getIrrelevantSets().size());
    // the following two counts are zero because the incomplete sets are not excluded!
    assertEquals(2, agreement.getIncompleteSetsByPosition().size());
    assertEquals(0, agreement.getIncompleteSetsByLabel().size());
    assertEquals(3, agreement.getSetsWithDifferences().size());
    assertEquals(4, agreement.getRelevantSetCount());
    assertEquals(0.4, agreement.getAgreement(), 0.01);
    ICodingAnnotationItem item1 = agreement.getStudy().getItem(0);
    ICodingAnnotationItem item2 = agreement.getStudy().getItem(1);
    ICodingAnnotationItem item3 = agreement.getStudy().getItem(2);
    assertEquals("", item1.getUnit(0).getCategory());
    assertEquals("", item1.getUnit(1).getCategory());
    assertEquals("", item2.getUnit(0).getCategory());
    assertEquals(null, item2.getUnit(1).getCategory());
    assertEquals(null, item3.getUnit(0).getCategory());
    assertEquals("", item3.getUnit(1).getCategory());
}
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) ICodingAnnotationItem(de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

ICodingAnnotationItem (de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationItem)4 IAnnotationUnit (de.tudarmstadt.ukp.dkpro.statistics.agreement.IAnnotationUnit)3 ArrayList (java.util.ArrayList)2 AgreementResult (de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult)1 ArcPosition (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcPosition)1 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)1 Position (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Position)1 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter)1 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)1 Arrays.asList (java.util.Arrays.asList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 JCas (org.apache.uima.jcas.JCas)1 Test (org.junit.Test)1