Search in sources :

Example 1 with JCasFactory.createJCas

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);
}
Also used : POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with JCasFactory.createJCas

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);
}
Also used : POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with JCasFactory.createJCas

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());
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) CasUtil.getType(org.apache.uima.fit.util.CasUtil.getType) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) FSUtil.getFeature(org.apache.uima.fit.util.FSUtil.getFeature) Feature(org.apache.uima.cas.Feature) Test(org.junit.Test)

Example 4 with JCasFactory.createJCas

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());
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) CasUtil.getType(org.apache.uima.fit.util.CasUtil.getType) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) FSUtil.getFeature(org.apache.uima.fit.util.FSUtil.getFeature) Feature(org.apache.uima.cas.Feature) Test(org.junit.Test)

Example 5 with JCasFactory.createJCas

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);
}
Also used : SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) JCasFactory.createJCas(org.apache.uima.fit.factory.JCasFactory.createJCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

JCasFactory.createJCas (org.apache.uima.fit.factory.JCasFactory.createJCas)8 JCas (org.apache.uima.jcas.JCas)8 ArrayList (java.util.ArrayList)6 Arrays.asList (java.util.Arrays.asList)6 LinkedHashMap (java.util.LinkedHashMap)6 List (java.util.List)6 Test (org.junit.Test)6 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff.DiffResult)4 Type (org.apache.uima.cas.Type)4 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)4 Feature (org.apache.uima.cas.Feature)3 CasUtil.getType (org.apache.uima.fit.util.CasUtil.getType)3 FSUtil.getFeature (org.apache.uima.fit.util.FSUtil.getFeature)3 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)3 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.span.SpanDiffAdapter)2 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)2 POS (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS)2 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)1 AnnotatorStateImpl (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl)1