Search in sources :

Example 1 with TextCorpusLayer

use of eu.clarin.weblicht.wlfxb.tc.api.TextCorpusLayer in project webanno by webanno.

the class TcfReaderWriterTest method testOneWay.

public void testOneWay(String aInputFile, String aExpectedFile) throws Exception {
    CollectionReaderDescription reader = createReaderDescription(TcfReader.class, TcfReader.PARAM_SOURCE_LOCATION, "src/test/resources/", TcfReader.PARAM_PATTERNS, aInputFile);
    AnalysisEngineDescription writer = createEngineDescription(TcfWriter.class, TcfWriter.PARAM_TARGET_LOCATION, "target/test-output/oneway", TcfWriter.PARAM_FILENAME_SUFFIX, ".xml", TcfWriter.PARAM_STRIP_EXTENSION, true);
    AnalysisEngineDescription dumper = createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_OUTPUT_FILE, "target/test-output/oneway/dump.txt");
    runPipeline(reader, writer, dumper);
    InputStream isReference = new FileInputStream(new File("src/test/resources/" + aExpectedFile));
    InputStream isActual = new FileInputStream(new File("target/test-output/oneway/" + aInputFile));
    WLData wLDataReference = WLDObjector.read(isReference);
    TextCorpusStored aCorpusDataReference = wLDataReference.getTextCorpus();
    WLData wLDataActual = WLDObjector.read(isActual);
    TextCorpusStored aCorpusDataActual = wLDataActual.getTextCorpus();
    // check if layers maintained
    assertEquals(aCorpusDataReference.getLayers().size(), aCorpusDataActual.getLayers().size());
    // Check if every layers have the same number of annotations
    for (TextCorpusLayer layer : aCorpusDataReference.getLayers()) {
        assertEquals("Layer size mismatch in [" + layer.getClass().getName() + "]", layer.size(), getLayer(aCorpusDataActual, layer.getClass()).size());
    }
    XMLAssert.assertXMLEqual(new InputSource("src/test/resources/" + aExpectedFile), new InputSource(new File("target/test-output/oneway/" + aInputFile).getPath()));
}
Also used : CollectionReaderDescription(org.apache.uima.collection.CollectionReaderDescription) TextCorpusLayer(eu.clarin.weblicht.wlfxb.tc.api.TextCorpusLayer) InputSource(org.xml.sax.InputSource) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TextCorpusStored(eu.clarin.weblicht.wlfxb.tc.xb.TextCorpusStored) AnalysisEngineDescription(org.apache.uima.analysis_engine.AnalysisEngineDescription) WLData(eu.clarin.weblicht.wlfxb.xb.WLData) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

TextCorpusLayer (eu.clarin.weblicht.wlfxb.tc.api.TextCorpusLayer)1 TextCorpusStored (eu.clarin.weblicht.wlfxb.tc.xb.TextCorpusStored)1 WLData (eu.clarin.weblicht.wlfxb.xb.WLData)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 AnalysisEngineDescription (org.apache.uima.analysis_engine.AnalysisEngineDescription)1 CollectionReaderDescription (org.apache.uima.collection.CollectionReaderDescription)1 InputSource (org.xml.sax.InputSource)1