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();
}
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();
}
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);
}
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());
}
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());
}
Aggregations