Search in sources :

Example 11 with TypeSystemDescription

use of org.apache.uima.resource.metadata.TypeSystemDescription in project webanno by webanno.

the class TypeSystemAnalysisTest method testSpanWithPrimitiveFeatures.

@Test
public void testSpanWithPrimitiveFeatures() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("tsd/spanWithPrimitiveFeatures");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    AnnotationLayer spanLayer = new AnnotationLayer();
    spanLayer.setName("webanno.custom.Span");
    spanLayer.setUiName("Span");
    spanLayer.setType(WebAnnoConst.SPAN_TYPE);
    spanLayer.setLockToTokenOffset(false);
    spanLayer.setAllowStacking(true);
    spanLayer.setCrossSentence(true);
    AnnotationFeature stringFeature = new AnnotationFeature("stringFeature", CAS.TYPE_NAME_STRING);
    AnnotationFeature intFeature = new AnnotationFeature("intFeature", CAS.TYPE_NAME_INTEGER);
    AnnotationFeature booleanFeature = new AnnotationFeature("booleanFeature", CAS.TYPE_NAME_BOOLEAN);
    AnnotationFeature floatFeature = new AnnotationFeature("floatFeature", CAS.TYPE_NAME_FLOAT);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).containsExactly(spanLayer).usingFieldByFieldElementComparator();
    softly.assertThat(analysis.getFeatures(spanLayer.getName())).containsExactlyInAnyOrder(stringFeature, intFeature, booleanFeature, floatFeature).usingFieldByFieldElementComparator();
    softly.assertAll();
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeSystemDescriptionFactory.createTypeSystemDescription(org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription) SoftAssertions(org.assertj.core.api.SoftAssertions) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Test(org.junit.Test)

Example 12 with TypeSystemDescription

use of org.apache.uima.resource.metadata.TypeSystemDescription in project webanno by webanno.

the class TypeSystemAnalysisTest method testSpanWithSlotFeatures.

@Test
public void testSpanWithSlotFeatures() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("tsd/spanWithSlotFeatures");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    AnnotationLayer slotSpanLayer = new AnnotationLayer();
    slotSpanLayer.setName("webanno.custom.SlotSpan");
    slotSpanLayer.setUiName("SlotSpan");
    slotSpanLayer.setType(WebAnnoConst.SPAN_TYPE);
    slotSpanLayer.setLockToTokenOffset(false);
    slotSpanLayer.setAllowStacking(true);
    slotSpanLayer.setCrossSentence(true);
    AnnotationFeature freeSlot = new AnnotationFeature("freeSlot", CAS.TYPE_NAME_ANNOTATION);
    AnnotationFeature boundSlot = new AnnotationFeature("boundSlot", "webanno.custom.SlotSpan");
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).containsExactly(slotSpanLayer).usingFieldByFieldElementComparator();
    softly.assertThat(analysis.getFeatures(slotSpanLayer.getName())).containsExactlyInAnyOrder(freeSlot, boundSlot).usingFieldByFieldElementComparator();
    softly.assertAll();
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeSystemDescriptionFactory.createTypeSystemDescription(org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription) SoftAssertions(org.assertj.core.api.SoftAssertions) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Test(org.junit.Test)

Example 13 with TypeSystemDescription

use of org.apache.uima.resource.metadata.TypeSystemDescription in project webanno by webanno.

the class TypeSystemAnalysisTest method testChain.

@Test
public void testChain() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("tsd/chain");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    AnnotationLayer chainLayer = new AnnotationLayer();
    chainLayer.setName("webanno.custom.Chain");
    chainLayer.setUiName("Chain");
    chainLayer.setType(WebAnnoConst.CHAIN_TYPE);
    chainLayer.setLockToTokenOffset(false);
    chainLayer.setAllowStacking(true);
    chainLayer.setCrossSentence(true);
    AnnotationFeature referenceRelationFeature = new AnnotationFeature("referenceRelation", CAS.TYPE_NAME_STRING);
    AnnotationFeature referenceTypeFeature = new AnnotationFeature("referenceType", CAS.TYPE_NAME_STRING);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).containsExactlyInAnyOrder(chainLayer).usingFieldByFieldElementComparator();
    softly.assertThat(analysis.getFeatures(chainLayer.getName())).containsExactlyInAnyOrder(referenceRelationFeature, referenceTypeFeature).usingFieldByFieldElementComparator();
    softly.assertAll();
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeSystemDescriptionFactory.createTypeSystemDescription(org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription) SoftAssertions(org.assertj.core.api.SoftAssertions) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Test(org.junit.Test)

Example 14 with TypeSystemDescription

use of org.apache.uima.resource.metadata.TypeSystemDescription in project webanno by webanno.

the class TypeSystemAnalysisTest method testRelationWithPrimitiveFeatures.

@Test
public void testRelationWithPrimitiveFeatures() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("tsd/relationWithPrimitiveFeatures");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    AnnotationLayer relationLayer = new AnnotationLayer();
    relationLayer.setName("webanno.custom.Relation");
    relationLayer.setUiName("Relation");
    relationLayer.setType(WebAnnoConst.RELATION_TYPE);
    relationLayer.setLockToTokenOffset(false);
    relationLayer.setAllowStacking(true);
    relationLayer.setCrossSentence(true);
    AnnotationLayer relationTargetLayer = new AnnotationLayer();
    relationTargetLayer.setName("webanno.custom.RelationTarget");
    relationTargetLayer.setUiName("RelationTarget");
    relationTargetLayer.setType(WebAnnoConst.SPAN_TYPE);
    relationTargetLayer.setLockToTokenOffset(false);
    relationTargetLayer.setAllowStacking(true);
    relationTargetLayer.setCrossSentence(true);
    AnnotationFeature stringFeature = new AnnotationFeature("stringFeature", CAS.TYPE_NAME_STRING);
    AnnotationFeature intFeature = new AnnotationFeature("intFeature", CAS.TYPE_NAME_INTEGER);
    AnnotationFeature booleanFeature = new AnnotationFeature("booleanFeature", CAS.TYPE_NAME_BOOLEAN);
    AnnotationFeature floatFeature = new AnnotationFeature("floatFeature", CAS.TYPE_NAME_FLOAT);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).containsExactlyInAnyOrder(relationLayer, relationTargetLayer).usingFieldByFieldElementComparator();
    softly.assertThat(analysis.getFeatures(relationLayer.getName())).containsExactlyInAnyOrder(stringFeature, intFeature, booleanFeature, floatFeature).usingFieldByFieldElementComparator();
    softly.assertAll();
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeSystemDescriptionFactory.createTypeSystemDescription(org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription) SoftAssertions(org.assertj.core.api.SoftAssertions) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) Test(org.junit.Test)

Example 15 with TypeSystemDescription

use of org.apache.uima.resource.metadata.TypeSystemDescription in project webanno by webanno.

the class TypeSystemAnalysisTest method testTheFullMonty.

@Test
public void testTheFullMonty() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("tsd/fullMonty");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).extracting(l -> l.getName() + ":" + l.getType()).hasSize(27).containsExactlyInAnyOrder("de.tudarmstadt.ukp.dkpro.core.api.coref.type.Coreference:chain", "de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.morph.Morpheme:span", "de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.morph.MorphologicalFeatures:span", "de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS:span", "de.tudarmstadt.ukp.dkpro.core.api.metadata.type.MetaDataStringField:span", "de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Div:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.LexicalPhrase:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.NGram:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Stem:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.StopWord:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.SurfaceForm:span", "de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.TokenForm:span", "de.tudarmstadt.ukp.dkpro.core.api.semantics.type.SemArg:span", "de.tudarmstadt.ukp.dkpro.core.api.semantics.type.SemPred:span", "de.tudarmstadt.ukp.dkpro.core.api.semantics.type.SemanticArgument:span", "de.tudarmstadt.ukp.dkpro.core.api.semantics.type.SemanticField:span", "de.tudarmstadt.ukp.dkpro.core.api.semantics.type.WordSense:span", "de.tudarmstadt.ukp.dkpro.core.api.syntax.type.PennTree:span", "de.tudarmstadt.ukp.dkpro.core.api.syntax.type.Tag:span", "de.tudarmstadt.ukp.dkpro.core.api.syntax.type.chunk.Chunk:span", "de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency:relation", "de.tudarmstadt.ukp.dkpro.core.api.transform.type.SofaChangeAnnotation:span", "webanno.custom.Chain:chain", "webanno.custom.Relation:relation", "webanno.custom.SlotSpan:span");
    softly.assertAll();
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeSystemDescriptionFactory.createTypeSystemDescription(org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription) SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Aggregations

TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)34 Test (org.junit.Test)23 JCas (org.apache.uima.jcas.JCas)13 ArrayList (java.util.ArrayList)11 TypeSystemDescriptionFactory.createTypeSystemDescription (org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription)10 SoftAssertions (org.assertj.core.api.SoftAssertions)9 CAS (org.apache.uima.cas.CAS)8 Type (org.apache.uima.cas.Type)7 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)6 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)6 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)5 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)5 Arrays.asList (java.util.Arrays.asList)5 List (java.util.List)5 SpanDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter)4 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)4 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)4 TypeSystem (org.apache.uima.cas.TypeSystem)4 TypeDescription (org.apache.uima.resource.metadata.TypeDescription)4 ArcDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter)3