Search in sources :

Example 16 with TypeSystemDescription

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

the class TypeSystemAnalysisTest method testCTakes40.

@Test
public void testCTakes40() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("3rd-party-tsd/ctakes-type-system-4_0");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).extracting(l -> l.getName() + ":" + l.getType()).hasSize(8).containsExactlyInAnyOrder("org.apache.ctakes.typesystem.type.textspan.Segment:span", "org.apache.ctakes.typesystem.type.textspan.Sentence:span", "org.apache.ctakes.typesystem.type.syntax.Chunk:span", "org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation:span", "org.apache.ctakes.typesystem.type.temporary.assertion.AssertionCuePhraseAnnotation:span", "org.apache.ctakes.typesystem.type.textspan.Paragraph:span", "org.apache.ctakes.typesystem.type.textspan.ListEntry:span", "org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation: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 17 with TypeSystemDescription

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

the class TypeSystemAnalysisTest method testTtcTermSuite.

@Test
public void testTtcTermSuite() throws Exception {
    TypeSystemDescription tsd = createTypeSystemDescription("3rd-party-tsd/ttc-term-suite");
    TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(analysis.getLayers()).extracting(l -> l.getName() + ":" + l.getType()).hasSize(4).containsExactlyInAnyOrder("eu.project.ttc.types.WordAnnotation:span", "eu.project.ttc.types.TermComponentAnnotation:span", "eu.project.ttc.types.TranslationCandidateAnnotation:span", "eu.project.ttc.types.FormAnnotation: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 18 with TypeSystemDescription

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

the class WebAnnoTsv3ReaderWriterRoundTripTest method runTest.

@Test
public void runTest() throws Exception {
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local;
    if (new File(referenceFolder, "typesystem.xml").exists()) {
        local = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(new File(referenceFolder, "typesystem.xml").toString());
    } else {
        local = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("src/test/resources/desc/type/webannoTestTypes.xml");
    }
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    String targetFolder = "target/test-output/WebAnnoTsv3ReaderWriterRoundTripTest/" + referenceFolder.getName();
    CollectionReaderDescription reader = createReaderDescription(WebannoTsv3Reader.class, merged, WebannoTsv3Reader.PARAM_SOURCE_LOCATION, referenceFolder, WebannoTsv3Reader.PARAM_PATTERNS, "reference.tsv");
    AnalysisEngineDescription checker = createEngineDescription(DKProCoreConventionsChecker.class);
    // WebannoTsv3Writer doesn't seem to like it if both "SimpleLinkHost" and
    // "ComplexLinkHost" are declared, so I comment out "ComplexLinkHost" which has
    // less tests.
    AnalysisEngineDescription tsvWriter = createEngineDescription(WebannoTsv3Writer.class, merged, WebannoTsv3Writer.PARAM_TARGET_LOCATION, targetFolder, WebannoTsv3Writer.PARAM_STRIP_EXTENSION, true, WebannoTsv3Writer.PARAM_CHAIN_LAYERS, asList("webanno.custom.Simple"), WebannoTsv3Writer.PARAM_SLOT_FEATS, asList("webanno.custom.SimpleLinkHost:links"), WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(NamedEntity.class.getName(), MorphologicalFeatures.class.getName(), POS.class.getName(), Lemma.class.getName(), Stem.class.getName(), "webanno.custom.SimpleSpan", "webanno.custom.SimpleLinkHost"), WebannoTsv3Writer.PARAM_LINK_TYPES, asList("webanno.custom.LinkType"), WebannoTsv3Writer.PARAM_SLOT_TARGETS, asList("webanno.custom.SimpleSpan"), WebannoTsv3Writer.PARAM_RELATION_LAYERS, asList("webanno.custom.SimpleRelation", "webanno.custom.Relation", "webanno.custom.ComplexRelation", Dependency.class.getName()));
    AnalysisEngineDescription xmiWriter = createEngineDescription(XmiWriter.class, merged, XmiWriter.PARAM_TARGET_LOCATION, targetFolder, XmiWriter.PARAM_STRIP_EXTENSION, true);
    try {
        SimplePipeline.runPipeline(reader, checker, tsvWriter, xmiWriter);
    } catch (Throwable e) {
        assumeFalse("This test is known to fail.", isKnownToFail(referenceFolder.getName()));
        throw e;
    }
    String reference = FileUtils.readFileToString(new File(referenceFolder, "reference.tsv"), "UTF-8");
    String actual = FileUtils.readFileToString(new File(targetFolder, "reference.tsv"), "UTF-8");
    // 
    // The XMI files here are not compared semantically but using their serialization which
    // is subject to minor variations depending e.g. on the order in which annotation are
    // created in the CAS. Thus, this code is commented out and should only be used on a
    // case-by-case base to compare XMIs during development.
    // 
    // String referenceXmi = FileUtils.readFileToString(new File(referenceFolder,
    // "reference.xmi"),
    // "UTF-8");
    // 
    // String actualXmi = FileUtils.readFileToString(new File(targetFolder, "reference.xmi"),
    // "UTF-8");
    assumeFalse("This test is known to fail.", isKnownToFail(referenceFolder.getName()));
    assertEquals(reference, actual);
// assertEquals(referenceXmi, actualXmi);
}
Also used : CollectionReaderDescription(org.apache.uima.collection.CollectionReaderDescription) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) AnalysisEngineDescription(org.apache.uima.analysis_engine.AnalysisEngineDescription) File(java.io.File) Test(org.junit.Test)

Example 19 with TypeSystemDescription

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

the class MergeCasTest method simpleSpanNoDiffMultiFeatureTest.

@Test
public void simpleSpanNoDiffMultiFeatureTest() throws Exception {
    TypeSystemDescription customeTypes = DiffUtils.createCustomTypeSystem(SPAN_TYPE, "webanno.custom.Opinion", asList("aspect", "opinion"), null);
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(customeTypes, "mergecas/spanmultifeature/1sentenceNENoFeature.tsv", "mergecas/spanmultifeature/1sentenceNENoFeature.tsv");
    List<String> entryTypes = asList("webanno.custom.Opinion");
    SpanDiffAdapter spanAdapter = new SpanDiffAdapter("webanno.custom.Opinion", "aspect", "opinion");
    List<SpanDiffAdapter> diffAdapters = asList(spanAdapter);
    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/spanmultifeature/1sentenceNENoFeature.tsv", customeTypes);
    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());
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) Test(org.junit.Test)

Example 20 with TypeSystemDescription

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

the class MergeCasTest method simpleSpanDiffMultiFeatureTest.

@Test
public void simpleSpanDiffMultiFeatureTest() throws Exception {
    TypeSystemDescription customeTypes = DiffUtils.createCustomTypeSystem(SPAN_TYPE, "webanno.custom.Opinion", asList("aspect", "opinion"), null);
    Map<String, List<JCas>> casByUser = DiffUtils.loadWebAnnoTSV(customeTypes, "mergecas/spanmultifeature/1sentenceNEFeatureA.tsv", "mergecas/spanmultifeature/1sentenceNEFeatureB.tsv");
    List<String> entryTypes = asList("webanno.custom.Opinion");
    SpanDiffAdapter spanAdapter = new SpanDiffAdapter("webanno.custom.Opinion", "aspect", "opinion");
    List<SpanDiffAdapter> diffAdapters = asList(spanAdapter);
    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/spanmultifeature/1sentenceNEFeatureempty.tsv", customeTypes);
    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());
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) SpanDiffAdapter(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.SpanDiffAdapter) JCas(org.apache.uima.jcas.JCas) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) DiffResult(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult) 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