本文整理汇总了Java中eu.clarin.weblicht.wlfxb.xb.WLData类的典型用法代码示例。如果您正苦于以下问题:Java WLData类的具体用法?Java WLData怎么用?Java WLData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WLData类属于eu.clarin.weblicht.wlfxb.xb包,在下文中一共展示了WLData类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNext
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
@Override
public void getNext(JCas aJCas)
throws IOException, CollectionException
{
Resource res = nextFile();
initCas(aJCas, res);
InputStream is = null;
try {
is = new BufferedInputStream(res.getInputStream());
WLData wLData = WLDObjector.read(is);
TextCorpus aCorpusData = wLData.getTextCorpus();
convertToCas(aJCas, aCorpusData);
}
catch (WLFormatException e) {
throw new CollectionException(e);
}
finally {
closeQuietly(is);
}
}
示例2: casToTcfWriter
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
/**
* Create TCF File from scratch
*
* @param aJCas
* the JCas.
* @param aOs
* the output stream.
* @throws WLFormatException
* if a TCF problem occurs.
*/
public void casToTcfWriter(JCas aJCas, OutputStream aOs)
throws WLFormatException
{
// create TextCorpus object, specifying its language from the aJcas Object
TextCorpusStored textCorpus = new TextCorpusStored(aJCas.getDocumentLanguage());
// create text annotation layer and add the string of the text into the layer
textCorpus.createTextLayer().addText(aJCas.getDocumentText());
write(aJCas, textCorpus);
// write the annotated data object into the output stream
WLData wldata = new WLData(textCorpus);
WLDObjector.write(wldata, aOs);
}
示例3: close
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
@Override
public void close() throws IOException {
try {
JAXBContext context = JAXBContext.newInstance(WLData.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(new WLData(corpus), corpusWriter);
} catch (JAXBException e) {
throw new IOException(e.getMessage());
}
corpusWriter.close();
}
示例4: read
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
public static WLData read(InputStream inputStream) throws WLFormatException {
WLData data = null;
try {
JAXBContext context = JAXBContext.newInstance(WLData.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
data = ((WLData) unmarshaller.unmarshal(inputStream));
} catch (JAXBException e) {
throw new WLFormatException(e.getMessage(), e);
}
return data;
}
示例5: testWrite_File
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
@Test
public void testWrite_File() throws Exception {
System.out.println("write");
File file = testFolder.newFile(OUTPUT_FILE_1);
WLData data = createWLTestData();
WLDObjector.write(data, file);
}
示例6: testRead
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
private void testRead(InputStream is) throws Exception {
System.out.println("read");
WLData wld = WLDObjector.read(is);
System.out.println(" --- " + wld.getMetaData());
System.out.println(" --- " + wld.getExternalData());
System.out.println(" --- " + wld.getTextCorpus());
System.out.println(" --- " + wld.getLexicon());
}
示例7: createWLTestData
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
private WLData createWLTestData() {
MetaData md = createTestMetadata();
TextCorpusStored tc = createTestTextCorpus();
ExternalDataStored ed = createTestExternalData();
WLData data = new WLData(md, ed, tc);
return data;
}
示例8: testWrite_File
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
@Test
public void testWrite_File() throws Exception {
System.out.println("write");
File file = testFolder.newFile(OUTPUT_FILE_1);
WLData data = createWLTestData();
WLDObjector.write(data, file, true);
}
示例9: testWriteUsingMinimumNsPrefixes_File
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
@Test
public void testWriteUsingMinimumNsPrefixes_File() throws Exception {
System.out.println("write");
File file = testFolder.newFile(OUTPUT_FILE_2);
WLData data = createWLTestData();
WLDObjector.write(data.getMetaData(), data.getTextCorpus(), file, false);
}
示例10: testRead
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
private void testRead(InputStream is) throws Exception {
System.out.println("read");
WLData wld = WLDObjector.read(is);
System.out.println(" --- " + wld.getMetaData());
System.out.println(" --- " + wld.getTextCorpus());
System.out.println(" --- " + wld.getLexicon());
}
示例11: testReadWrite
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
@Test
public void testReadWrite() throws Exception {
InputStream is = this.getClass().getResourceAsStream(INPUT_FILE);
WLData wld = WLDObjector.read(is);
WLDObjector.write(wld, testFolder.newFile(OUTPUT_FILE), false);
InputStream is2 = new FileInputStream(testFolder.newFile(OUTPUT_FILE));
// TODO: can use after equal methods are implemented for TCF components
//WLData wld2 = WLDObjector.read(is2);
//Assert.assertEquals("tcf after read->write->read should be equal", wld, wld2);
InputStream is3 = this.getClass().getResourceAsStream(INPUT_FILE);
TestUtils.assertEqualXml(is3, is2);
}
示例12: testOneWay
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
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()));
}
示例13: write
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
public static void write(WLData wlData, OutputStream outputStream) throws WLFormatException {
write(wlData.getMetaData(), wlData.getTextCorpus(), outputStream, false);
}
示例14: createWLTestData
import eu.clarin.weblicht.wlfxb.xb.WLData; //导入依赖的package包/类
private WLData createWLTestData() {
MetaData md = createTestMetadata();
TextCorpusStored tc = createTestTextCorpus();
WLData data = new WLData(md, tc);
return data;
}