Search in sources :

Example 31 with TypeSystemDescription

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

the class TypeSystemAnalysisTest method testCreta.

@Test
public void testCreta() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("3rd-party-tsd/creta-typesystem");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).extracting(l -> l.getName() + ":" + l.getType()).hasSize(58).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.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.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.uni_potsdam.acl.type.Chunk:span", "de.uni_potsdam.acl.type.ClusteredEventMention:span", "de.uni_potsdam.acl.type.Mention:span", "de.uni_potsdam.acl.type.Negation:span", "de.uni_potsdam.acl.type.Sentiment:span", "de.unihd.dbs.uima.types.heideltime.Dct:span", "de.unihd.dbs.uima.types.heideltime.Sentence:span", "de.unihd.dbs.uima.types.heideltime.SourceDocInfo:span", "de.unihd.dbs.uima.types.heideltime.Timex3:span", "de.unihd.dbs.uima.types.heideltime.Timex3Interval:span", "de.unihd.dbs.uima.types.heideltime.Token:span", "de.unistuttgart.ims.creta.api.Entity:span", "de.unistuttgart.ims.creta.api.ExampleType:span", "de.unistuttgart.ims.creta.api.Format:span", "de.unistuttgart.ims.creta.api.Line:span", "de.unistuttgart.ims.creta.api.Quotation:span", "de.unistuttgart.ims.creta.api.Stage:span", "de.unistuttgart.ims.creta.api.Utterance:span", "de.unistuttgart.ims.type.Agenda:span", "de.unistuttgart.ims.type.Chunk:span", "de.unistuttgart.ims.type.HumanAnnotation:span", "de.unistuttgart.ims.type.Keyword:span", "de.unistuttgart.ims.type.Link:span", "de.unistuttgart.ims.type.Markable:span", "de.unistuttgart.ims.type.NE:span", "de.unistuttgart.ims.type.Paragraph:span", "de.unistuttgart.ims.type.Quotation:span", "de.unistuttgart.ims.type.Section:span", "de.unistuttgart.ims.type.Sentence:span", "de.unistuttgart.ims.type.Speaker:span", "de.unistuttgart.ims.type.Token:span", "de.unistuttgart.ims.uimautil.WordListDescription:span", "org.cleartk.ne.type.Ace2005Document:span", "org.cleartk.ne.type.Chunk:span", "org.cleartk.score.type.ScoredAnnotation:span", "org.cleartk.srl.type.Chunk:span", "org.cleartk.timeml.type.Anchor:span", "org.cleartk.timeml.type.Event:span", "org.cleartk.token.type.Subtoken:span", "org.cleartk.token.type.Token: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)

Example 32 with TypeSystemDescription

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

the class TypeSystemAnalysisTest method testCcpTypeSystem.

@Test
public void testCcpTypeSystem() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("3rd-party-tsd/CcpTypeSystem");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).hasSize(0);
    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)

Example 33 with TypeSystemDescription

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

the class AllAnnotationsIndexedCheckTest method testOK.

@Test
public void testOK() throws Exception {
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory().createTypeSystemDescription();
    String refTypeName = "RefType";
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    Type refType = cas.getTypeSystem().getType(refTypeName);
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);
    // An indexed annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno2);
    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    messages.forEach(System.out::println);
    assertTrue(result);
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) CAS(org.apache.uima.cas.CAS) LogMessage(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage) ArrayList(java.util.ArrayList) CasDoctor(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) Test(org.junit.Test)

Example 34 with TypeSystemDescription

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

the class AllAnnotationsIndexedCheckTest method testFail.

@Test
public void testFail() throws Exception {
    TypeSystemDescription tsd = UIMAFramework.getResourceSpecifierFactory().createTypeSystemDescription();
    String refTypeName = "RefType";
    TypeDescription refTypeDesc = tsd.addType(refTypeName, null, CAS.TYPE_NAME_ANNOTATION);
    refTypeDesc.addFeature("ref", null, CAS.TYPE_NAME_ANNOTATION);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    Type refType = cas.getTypeSystem().getType(refTypeName);
    // A regular index annotation
    AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    cas.addFsToIndexes(anno1);
    // A non-index annotation but reachable through an indexe one (below)
    AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
    // An indexed annotation that references the non-indexed annotation above
    AnnotationFS anno3 = cas.createAnnotation(refType, 0, 1);
    anno3.setFeatureValue(refType.getFeatureByBaseName("ref"), anno2);
    cas.addFsToIndexes(anno3);
    List<LogMessage> messages = new ArrayList<>();
    CasDoctor cd = new CasDoctor(AllFeatureStructuresIndexedCheck.class);
    // A project is not required for this check
    boolean result = cd.analyze(null, cas, messages);
    messages.forEach(System.out::println);
    assertFalse(result);
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) Type(org.apache.uima.cas.Type) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) CAS(org.apache.uima.cas.CAS) LogMessage(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor.LogMessage) ArrayList(java.util.ArrayList) CasDoctor(de.tudarmstadt.ukp.clarin.webanno.diag.CasDoctor) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) 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