use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasDiffTest method spanLabelLabelTest.
@Test
public void spanLabelLabelTest() throws Exception {
Map<String, List<CAS>> casByUser = load("casdiff/spanLabel/user1.conll", "casdiff/spanLabel/user2.conll");
List<? extends DiffAdapter> diffAdapters = asList(new SpanDiffAdapter(POS.class.getName(), "PosValue"));
CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
DiffResult result = diff.toResult();
// result.print(System.out);
assertEquals(26, 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, entryTypes.get(0),
// "PosValue", casByUser);
// assertEquals(0.958730d, agreement.getAgreement(), 0.000001d);
// assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasDiffTest method noDifferencesDependencyTest.
@Test
public void noDifferencesDependencyTest() throws Exception {
Map<String, List<CAS>> casByUser = load("casdiff/noDifferences/data.conll", "casdiff/noDifferences/data.conll");
List<? extends DiffAdapter> diffAdapters = asList(DEPENDENCY_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), "DependencyType", casByUser);
// assertEquals(1.0d, agreement.getAgreement(), 0.000001d);
// assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasDiffTest method multiLinkWithRoleMultiTargetDifferenceTest2.
@Test
public void multiLinkWithRoleMultiTargetDifferenceTest2() 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, "slot2", 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(3, diff.size());
assertEquals(1, diff.getDifferingConfigurationSets().size());
assertEquals(2, 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);
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasDiffTest method multipleEmptyCasWithMissingOnesTest.
@Test
public void multipleEmptyCasWithMissingOnesTest() throws Exception {
String text = "";
CAS user1Cas1 = null;
CAS user1Cas2 = null;
CAS user1Cas3 = JCasFactory.createJCas().getCas();
user1Cas3.setDocumentText(text);
CAS user1Cas4 = JCasFactory.createJCas().getCas();
user1Cas4.setDocumentText(text);
CAS user2Cas1 = JCasFactory.createJCas().getCas();
user2Cas1.setDocumentText(text);
CAS user2Cas2 = null;
CAS user2Cas3 = null;
CAS user2Cas4 = JCasFactory.createJCas().getCas();
user2Cas4.setDocumentText(text);
Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(user1Cas1, user1Cas2, user1Cas3, user1Cas4));
casByUser.put("user2", asList(user2Cas1, user2Cas2, user2Cas3, user2Cas4));
List<SpanDiffAdapter> diffAdapters = asList(new SpanDiffAdapter(Lemma.class.getName()));
CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
DiffResult result = diff.toResult();
// result.print(System.out);
assertEquals(0, 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), "value", casByUser);
// assertEquals(Double.NaN, agreement.getAgreement(), 0.000001d);
// assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult in project webanno by webanno.
the class CasDiffTest method relationStackedSpansTest.
@Test
public void relationStackedSpansTest() throws Exception {
TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
TypeSystemDescription local = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("src/test/resources/desc/type/webannoTestTypes.xml");
TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class, Sentence.class);
JCas jcasA = JCasFactory.createJCas(merged);
{
CAS casA = jcasA.getCas();
tb.buildTokens(jcasA, "This is a test .");
List<Token> tokensA = new ArrayList<>(select(jcasA, Token.class));
Token t1A = tokensA.get(0);
Token t2A = tokensA.get(tokensA.size() - 1);
NamedEntity govA = new NamedEntity(jcasA, t1A.getBegin(), t1A.getEnd());
govA.addToIndexes();
// Here we add a stacked named entity!
new NamedEntity(jcasA, t1A.getBegin(), t1A.getEnd()).addToIndexes();
NamedEntity depA = new NamedEntity(jcasA, t2A.getBegin(), t2A.getEnd());
depA.addToIndexes();
Type relationTypeA = casA.getTypeSystem().getType("webanno.custom.Relation");
AnnotationFS fs1A = casA.createAnnotation(relationTypeA, depA.getBegin(), depA.getEnd());
FSUtil.setFeature(fs1A, "Governor", govA);
FSUtil.setFeature(fs1A, "Dependent", depA);
FSUtil.setFeature(fs1A, "value", "REL");
casA.addFsToIndexes(fs1A);
}
JCas jcasB = JCasFactory.createJCas(merged);
{
CAS casB = jcasB.getCas();
tb.buildTokens(jcasB, "This is a test .");
List<Token> tokensB = new ArrayList<>(select(jcasB, Token.class));
Token t1B = tokensB.get(0);
Token t2B = tokensB.get(tokensB.size() - 1);
NamedEntity govB = new NamedEntity(jcasB, t1B.getBegin(), t1B.getEnd());
govB.addToIndexes();
NamedEntity depB = new NamedEntity(jcasB, t2B.getBegin(), t2B.getEnd());
depB.addToIndexes();
Type relationTypeB = casB.getTypeSystem().getType("webanno.custom.Relation");
AnnotationFS fs1B = casB.createAnnotation(relationTypeB, depB.getBegin(), depB.getEnd());
FSUtil.setFeature(fs1B, "Governor", govB);
FSUtil.setFeature(fs1B, "Dependent", depB);
FSUtil.setFeature(fs1B, "value", "REL");
casB.addFsToIndexes(fs1B);
}
Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(jcasA.getCas()));
casByUser.put("user2", asList(jcasB.getCas()));
List<? extends DiffAdapter> diffAdapters = asList(new RelationDiffAdapter("webanno.custom.Relation", WebAnnoConst.FEAT_REL_TARGET, WebAnnoConst.FEAT_REL_SOURCE, "value"));
CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
DiffResult result = diff.toResult();
// result.print(System.out);
assertEquals(1, 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,
// "webanno.custom.Relation", "value", casByUser);
//
// // Asserts
// System.out.printf("Agreement: %s%n", agreement.toString());
// AgreementUtils.dumpAgreementStudy(System.out, agreement);
//
// assertEquals(1, agreement.getPluralitySets().size());
}
Aggregations