Search in sources :

Example 11 with SpanDiffAdapter

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

the class MergeCasTest method simpleSpanDiffNoLabelTest.

@Test
public void simpleSpanDiffNoLabelTest() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentence.tsv", "mergecas/simplespan/1sentenceempty.tsv");
    List<String> entryTypes = asList(POS.class.getName());
    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);
    addRandomMergeCas(casByUser);
    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
    casByUser = new HashMap<>();
    JCas actual = DiffUtils.readWebAnnoTSV("mergecas/simplespan/1sentenceempty.tsv", null);
    casByUser.put("actual", asList(actual));
    casByUser.put("merge", asList(mergeCas));
    result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : 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) Test(org.junit.Test)

Example 12 with SpanDiffAdapter

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

the class MergeCasTest method multiLinkMultiHostTest.

@Test
public void multiLinkMultiHostTest() throws Exception {
    JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
    DiffUtils.makeLinkHostFS(jcasA, 0, 0, DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
    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, "slot1", 0, 0));
    Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(jcasA));
    casByUser.put("user2", asList(jcasB));
    casByUser.put(CURATION_USER, 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 result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    result.print(System.out);
    JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
    Type hostType = mergeCas.getTypeSystem().getType(DiffUtils.HOST_TYPE);
    int numHost = CasUtil.select(mergeCas.getCas(), hostType).size();
    assertEquals(0, numHost);
}
Also used : Type(org.apache.uima.cas.Type) 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 13 with SpanDiffAdapter

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

the class MergeCasTest method simpleSpanDiffWithLabelAndEmptyTest.

@Test
public void simpleSpanDiffWithLabelAndEmptyTest() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentence.tsv", "mergecas/simplespan/1sentenceempty.tsv");
    List<String> entryTypes = asList(POS.class.getName());
    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);
    addRandomMergeCas(casByUser);
    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
    casByUser = new HashMap<>();
    JCas actual = DiffUtils.readWebAnnoTSV("mergecas/simplespan/1sentenceempty.tsv", null);
    casByUser.put("actual", asList(actual));
    casByUser.put("merge", asList(mergeCas));
    result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : 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) Test(org.junit.Test)

Example 14 with SpanDiffAdapter

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

the class MergeCasTest method simpleSpanDiffWithLabelStacking3Test.

@Test
public void simpleSpanDiffWithLabelStacking3Test() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentenceNE.tsv", "mergecas/simplespan/1sentenceNEstacked2.tsv");
    List<String> entryTypes = asList(NamedEntity.class.getName());
    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.NER);
    addRandomMergeCas(casByUser);
    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
    casByUser = new HashMap<>();
    JCas actual = DiffUtils.readWebAnnoTSV("mergecas/simplespan/1sentenceNEstacked2merge.tsv", null);
    casByUser.put("actual", asList(actual));
    casByUser.put("merge", asList(mergeCas));
    result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : NamedEntity(de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity) 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) Test(org.junit.Test)

Example 15 with SpanDiffAdapter

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

the class MergeCasTest method simpleSpanNoDiffNoLabelTest.

@Test
public void simpleSpanNoDiffNoLabelTest() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentence.tsv", "mergecas/simplespan/1sentence.tsv");
    List<String> entryTypes = asList(POS.class.getName());
    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);
    addRandomMergeCas(casByUser);
    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    JCas mergeCas = MergeCas.reMergeCas(result, getSingleCasByUser(casByUser));
    casByUser = new HashMap<>();
    JCas actual = DiffUtils.readWebAnnoTSV("mergecas/simplespan/1sentence.tsv", null);
    casByUser.put("actual", asList(actual));
    casByUser.put("merge", asList(mergeCas));
    result = CasDiff2.doDiff(entryTypes, diffAdapters, LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
}
Also used : 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) Test(org.junit.Test)

Aggregations

Arrays.asList (java.util.Arrays.asList)38 List (java.util.List)38 Test (org.junit.Test)38 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)36 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter)36 ArrayList (java.util.ArrayList)36 JCas (org.apache.uima.jcas.JCas)33 LinkedHashMap (java.util.LinkedHashMap)21 AgreementResult (de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult)16 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)15 Type (org.apache.uima.cas.Type)7 FeatureStructure (org.apache.uima.cas.FeatureStructure)4 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)4 NamedEntity (de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity)3 Feature (org.apache.uima.cas.Feature)3 CasDiff2 (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2)2 ArcDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter)2 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)2 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)2