Search in sources :

Example 31 with CasDiff2

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

the class MergeCasTest method multiLinkWithRoleNoDifferenceTest.

@Test
public void multiLinkWithRoleNoDifferenceTest() throws Exception {
    JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
    DiffUtils.makeLinkHostFS(jcasA, 0, 0, DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
    DiffUtils.makeLinkHostFS(jcasA, 10, 10, DiffUtils.makeLinkFS(jcasA, "slot1", 10, 10));
    JCas jcasB = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem());
    DiffUtils.makeLinkHostFS(jcasB, 0, 0, DiffUtils.makeLinkFS(jcasB, "slot1", 0, 0));
    DiffUtils.makeLinkHostFS(jcasB, 10, 10, DiffUtils.makeLinkFS(jcasB, "slot1", 10, 10));
    Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
    casByUser.put("user1", asList(jcasA));
    casByUser.put("user2", asList(jcasB));
    casByUser.put(CURATION_USER, asList(jcasA));
    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));
    casByUser = new HashMap<>();
    casByUser.put("actual", asList(jcasA));
    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 : 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 32 with CasDiff2

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

the class MergeCasTest method simpleSpanDiffWithLabelStacking2Test.

@Test
public void simpleSpanDiffWithLabelStacking2Test() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentenceNE.tsv", "mergecas/simplespan/1sentenceNEstacked.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/1sentenceNEempty.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 33 with CasDiff2

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

the class MergeCasTest method simpleSpanDiffMultiFeatureTest.

@Test
public void simpleSpanDiffMultiFeatureTest() throws Exception {
    TypeSystemDescription customeTypes = DiffUtils.createCustomTypeSystem(SPAN_TYPE, "webanno.custom.Opinion", asList("aspect", "opinion"), null);
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(customeTypes, "mergecas/spanmultifeature/1sentenceNEFeatureA.tsv", "mergecas/spanmultifeature/1sentenceNEFeatureB.tsv");
    List<String> entryTypes = asList("webanno.custom.Opinion");
    SpanDiffAdapter spanAdapter = new SpanDiffAdapter("webanno.custom.Opinion", "aspect", "opinion");
    List<SpanDiffAdapter> diffAdapters = asList(spanAdapter);
    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/spanmultifeature/1sentenceNEFeatureempty.tsv", customeTypes);
    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 : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) 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 34 with CasDiff2

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

the class MergeCasTest method simpleRelGovStackedTest.

@Test
public void simpleRelGovStackedTest() throws Exception {
    TypeSystemDescription customeTypesSpan = DiffUtils.createCustomTypeSystem(SPAN_TYPE, "webanno.custom.Multivalspan", asList("f1", "f2"), null);
    TypeSystemDescription customeTypesRel = DiffUtils.createCustomTypeSystem(RELATION_TYPE, "webanno.custom.Multivalrel", asList("rel1", "rel2"), "webanno.custom.Multivalspan");
    List<TypeSystemDescription> customTypes = new ArrayList<>();
    customTypes.add(customeTypesSpan);
    customTypes.add(customeTypesRel);
    TypeSystemDescription customType = CasCreationUtils.mergeTypeSystems(customTypes);
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(customType, "mergecas/multivalspanrel/tale.tsv", "mergecas/multivalspanrel/tale.tsv");
    List<String> entryTypes = asList("webanno.custom.Multivalspan", "webanno.custom.Multivalrel");
    List<? extends DiffAdapter> diffAdapters = asList(new ArcDiffAdapter("webanno.custom.Multivalrel", "Dependent", "Governor", "rel1", "rel2"), new SpanDiffAdapter("webanno.custom.Multivalspan", "f1", "f2"));
    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/multivalspanrel/tale2.tsv", customType);
    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 : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) ArcDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) ArrayList(java.util.ArrayList) 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 35 with CasDiff2

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

the class MergeCasTest method simpleRelNoDiffTest.

@Test
public void simpleRelNoDiffTest() throws Exception {
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/rels/1sentencesamerel.tsv", "mergecas/rels/1sentencesamerel.tsv");
    List<String> entryTypes = asList(Dependency.class.getName(), POS.class.getName());
    List<? extends DiffAdapter> diffAdapters = asList(new ArcDiffAdapter(Dependency.class.getName(), "Dependent", "Governor", "DependencyType"), 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/rels/1sentencesamerel.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 : ArcDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter) POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) JCas(org.apache.uima.jcas.JCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Dependency(de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) Test(org.junit.Test)

Aggregations

DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)52 List (java.util.List)52 Arrays.asList (java.util.Arrays.asList)51 Test (org.junit.Test)51 ArrayList (java.util.ArrayList)48 JCas (org.apache.uima.jcas.JCas)44 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter)37 LinkedHashMap (java.util.LinkedHashMap)26 AgreementResult (de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult)24 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)20 ArcDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter)12 Type (org.apache.uima.cas.Type)12 Dependency (de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency)11 HashMap (java.util.HashMap)8 Map (java.util.Map)8 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)6 User (de.tudarmstadt.ukp.clarin.webanno.security.model.User)5 FeatureStructure (org.apache.uima.cas.FeatureStructure)5 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)5 NamedEntity (de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity)4