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++;
}
}
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++;
}
}
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);
}
}
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());
}
Aggregations