use of org.apache.uima.fit.factory.JCasFactory.createJCas in project webanno by webanno.
the class AgreementMeasureTestSuite_ImplBase method twoWithoutLabelTest.
public <R extends Serializable, T extends DefaultAgreementTraits> R twoWithoutLabelTest(AgreementMeasureSupport<T, R, ICodingAnnotationStudy> aSupport, T aTraits) throws Exception {
AnnotationLayer layer = new AnnotationLayer(POS.class.getName(), POS.class.getSimpleName(), SPAN_TYPE, project, false, SINGLE_TOKEN, NO_OVERLAP);
layer.setId(1l);
layers.add(layer);
AnnotationFeature feature = new AnnotationFeature(project, layer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING);
feature.setId(1l);
features.add(feature);
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<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(user1.getCas()));
casByUser.put("user2", asList(user2.getCas()));
AgreementMeasure<R> measure = aSupport.createMeasure(feature, aTraits);
return measure.getAgreement(casByUser);
}
use of org.apache.uima.fit.factory.JCasFactory.createJCas in project webanno by webanno.
the class AgreementMeasureTestSuite_ImplBase method singleNoDifferencesWithAdditionalCasTest.
public <R extends Serializable, T extends DefaultAgreementTraits> R singleNoDifferencesWithAdditionalCasTest(AgreementMeasureSupport<T, R, ICodingAnnotationStudy> aSupport) throws Exception {
AnnotationLayer layer = new AnnotationLayer(POS.class.getName(), POS.class.getSimpleName(), SPAN_TYPE, project, false, SINGLE_TOKEN, NO_OVERLAP);
layer.setId(1l);
layers.add(layer);
AnnotationFeature feature = new AnnotationFeature(project, layer, "PosValue", "PosValue", CAS.TYPE_NAME_STRING);
feature.setId(1l);
features.add(feature);
T traits = aSupport.createTraits();
JCas user1 = JCasFactory.createJCas();
user1.setDocumentText("test");
JCas user2 = JCasFactory.createJCas();
user2.setDocumentText("test");
JCas user3 = JCasFactory.createJCas();
user3.setDocumentText("test");
POS pos3 = new POS(user3, 0, 4);
pos3.setPosValue("test");
pos3.addToIndexes();
Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(user1.getCas()));
casByUser.put("user2", asList(user2.getCas()));
casByUser.put("user3", asList(user3.getCas()));
AgreementMeasure<R> measure = aSupport.createMeasure(feature, traits);
return measure.getAgreement(casByUser);
}
use of org.apache.uima.fit.factory.JCasFactory.createJCas in project webanno by webanno.
the class CasMergeTest method copySpanWithSlotWithStackingTest.
@Test
public void copySpanWithSlotWithStackingTest() throws Exception {
AnnotatorState state = new AnnotatorStateImpl(CURATION);
state.setUser(new User());
slotLayer.setAnchoringMode(TOKENS);
slotLayer.setOverlapMode(OverlapMode.ANY_OVERLAP);
JCas jcasA = createJCas(CurationTestUtils.createMultiLinkWithRoleTestTypeSystem("f1"));
Type type = jcasA.getTypeSystem().getType(CurationTestUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
AnnotationFS clickedFs = CurationTestUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", CurationTestUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas mergeCAs = JCasFactory.createJCas(CurationTestUtils.createMultiLinkWithRoleTestTypeSystem("f1"));
CurationTestUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", CurationTestUtils.makeLinkFS(mergeCAs, "slot1", 0, 0));
sut.mergeSpanAnnotation(null, null, slotLayer, mergeCAs.getCas(), clickedFs, true);
assertEquals(2, selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
use of org.apache.uima.fit.factory.JCasFactory.createJCas in project webanno by webanno.
the class CasMergeTest method copySpanWithSlotNoStackingTest.
@Test
public void copySpanWithSlotNoStackingTest() throws Exception {
slotLayer.setOverlapMode(OverlapMode.NO_OVERLAP);
JCas jcasA = createJCas(CurationTestUtils.createMultiLinkWithRoleTestTypeSystem("f1"));
Type type = jcasA.getTypeSystem().getType(CurationTestUtils.HOST_TYPE);
Feature feature = type.getFeatureByBaseName("f1");
AnnotationFS clickedFs = CurationTestUtils.makeLinkHostMultiSPanFeatureFS(jcasA, 0, 0, feature, "A", CurationTestUtils.makeLinkFS(jcasA, "slot1", 0, 0));
JCas mergeCAs = JCasFactory.createJCas(CurationTestUtils.createMultiLinkWithRoleTestTypeSystem("f1"));
CurationTestUtils.makeLinkHostMultiSPanFeatureFS(mergeCAs, 0, 0, feature, "C", CurationTestUtils.makeLinkFS(mergeCAs, "slot1", 0, 0));
sut.mergeSpanAnnotation(null, null, slotLayer, mergeCAs.getCas(), clickedFs, false);
assertEquals(1, selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
use of org.apache.uima.fit.factory.JCasFactory.createJCas 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);
}
Aggregations