use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2 in project webanno by webanno.
the class MergeCasTest method simpleSpanDiffWithLabelTest.
@Test
public void simpleSpanDiffWithLabelTest() throws Exception {
Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/simplespan/1sentenceposlabel.tsv", "mergecas/simplespan/1sentenceposlabel2.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());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2 in project webanno by webanno.
the class MergeCasTest method simpleRelGovDiffTest.
@Test
public void simpleRelGovDiffTest() throws Exception {
Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(null, "mergecas/rels/1sentencesamerel.tsv", "mergecas/rels/1sentencesamerel2.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/1sentencesamerel3.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());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2 in project webanno by webanno.
the class MergeCasTest method multiLinkMultiSpanRoleDiffTest.
@Test
public void multiLinkMultiSpanRoleDiffTest() throws Exception {
JCas jcasA = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
Type type = jcasA.getTypeSystem().getType(DiffUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas jcasB = JCasFactory.createJCas(DiffUtils.createMultiLinkWithRoleTestTypeSytem("f1"));
DiffUtils.makeLinkHostMultiSPanFeatureFS(jcasB, 0, 0, feature, "A", DiffUtils.makeLinkFS(jcasB, "slot2", 0, 0));
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));
Type hostType = mergeCas.getTypeSystem().getType(DiffUtils.HOST_TYPE);
int numHost = CasUtil.select(mergeCas.getCas(), hostType).size();
assertEquals(1, numHost);
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2 in project webanno by webanno.
the class MergeCasTest method relStackedTest.
@Test
public void relStackedTest() 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.loadXMI(customType, "mergecas/multivalspanrel/stackedrel1.xmi", "mergecas/multivalspanrel/stackedrel2.xmi");
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));
JCas actual = DiffUtils.readXMI("mergecas/multivalspanrel/stackedmerge.xmi", customType);
Type relType = mergeCas.getTypeSystem().getType("webanno.custom.Multivalrel");
int numRelMerge = CasUtil.select(mergeCas.getCas(), relType).size();
int numRelActual = CasUtil.select(actual.getCas(), relType).size();
Type spanType = mergeCas.getTypeSystem().getType("webanno.custom.Multivalspan");
int numspanMerge = CasUtil.select(mergeCas.getCas(), spanType).size();
int numspanActual = CasUtil.select(actual.getCas(), spanType).size();
assertEquals(2, numRelMerge);
assertEquals(2, numRelActual);
assertEquals(4, numspanMerge);
assertEquals(4, numspanActual);
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2 in project webanno by webanno.
the class SuggestionViewPanel method calcColors.
private Map<String, Map<VID, AnnotationState>> calcColors(AnnotatorState state, SourceListView aCurationSegment, JCas annotatorCas, Map<String, JCas> jCases) {
// get differing feature structures
List<Type> entryTypes = SuggestionBuilder.getEntryTypes(annotatorCas, state.getAnnotationLayers(), annotationService);
Map<String, Map<VID, AnnotationState>> annoStates = new HashMap<>();
DiffResult diff;
if (state.getMode().equals(Mode.CURATION)) {
diff = CasDiff2.doDiffSingle(annotationService, state.getProject(), entryTypes, LinkCompareBehavior.LINK_ROLE_AS_LABEL, jCases, aCurationSegment.getCurationBegin(), aCurationSegment.getCurationEnd());
} else {
diff = CasDiff2.doDiffSingle(annotationService, state.getProject(), entryTypes, LinkCompareBehavior.LINK_ROLE_AS_LABEL, jCases, aCurationSegment.getBegin(), aCurationSegment.getEnd());
}
Collection<ConfigurationSet> d = diff.getDifferingConfigurationSets().values();
Collection<ConfigurationSet> i = diff.getIncompleteConfigurationSets().values();
for (ConfigurationSet cfgSet : d) {
if (i.contains(cfgSet)) {
i.remove(cfgSet);
}
}
addSuggestionColor(state.getProject(), state.getMode(), jCases, annoStates, d, false, false);
addSuggestionColor(state.getProject(), state.getMode(), jCases, annoStates, i, true, false);
List<ConfigurationSet> all = new ArrayList<>();
all.addAll(diff.getConfigurationSets());
all.removeAll(d);
all.removeAll(i);
addSuggestionColor(state.getProject(), state.getMode(), jCases, annoStates, all, false, true);
return annoStates;
}
Aggregations