本文整理了Java中org.apache.uima.cas.impl.XCASSerializer.<init>()
方法的一些代码示例,展示了XCASSerializer.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XCASSerializer.<init>()
方法的具体详情如下:
包路径:org.apache.uima.cas.impl.XCASSerializer
类名称:XCASSerializer
方法名:<init>
暂无
代码示例来源:origin: org.apache.ctakes/ctakes-assertion
private void writeXCas(CAS aCas, String fileName) throws IOException, SAXException {
File outFile = new File(outputDirectory, fileName + ".xcas");
FileOutputStream out = null;
try {
out = new FileOutputStream(outFile);
XCASSerializer ser = new XCASSerializer(aCas.getTypeSystem());
XMLSerializer xmlSer = new XMLSerializer(out, false);
ser.serialize(aCas, xmlSer.getContentHandler());
}
finally {
if (out != null) {
out.close();
}
}
}
代码示例来源:origin: apache/ctakes
private void writeXCas(CAS aCas, String fileName) throws IOException, SAXException {
File outFile = new File(outputDirectory, fileName + ".xcas");
FileOutputStream out = null;
try {
out = new FileOutputStream(outFile);
XCASSerializer ser = new XCASSerializer(aCas.getTypeSystem());
XMLSerializer xmlSer = new XMLSerializer(out, false);
ser.serialize(aCas, xmlSer.getContentHandler());
}
finally {
if (out != null) {
out.close();
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.bigdata/de.tudarmstadt.ukp.dkpro.bigdata.io.hadoop
/**
* Returns XML (XCAS) representation of this CAS, stripped of all newlines.
*/
@Override
public String toString()
{
if (cas == null)
return "null";
// Use StringWriter instead of OutputStream for XMLSerializer so that
// we don't need to worry about string encoding (utf-8 vs. utf-16, etc.)
StringWriter writer = new StringWriter();
XMLSerializer xmlSerializer = new XMLSerializer(writer);
XCASSerializer casSerializer = new XCASSerializer(cas.getTypeSystem());
try {
casSerializer.serialize(cas, xmlSerializer.getContentHandler());
}
catch (SAXException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
String xml = writer.toString();
xml = xml.replace("\n", "");
return xml;
}
代码示例来源:origin: org.apache.uima/uimaj-tools
/**
* Serialize a CAS to a file in XCAS format
*
* @param aCas
* CAS to serialize
* @param name
* output file
*
* @throws IOException
* if an I/O failure occurs
* @throws SAXException
* if an error occurs generating the XML text
*/
private void writeXCas(CAS aCas, File name) throws IOException, SAXException {
FileOutputStream out = null;
try {
out = new FileOutputStream(name);
XCASSerializer ser = new XCASSerializer(aCas.getTypeSystem());
XMLSerializer sax2xml = new XMLSerializer(out, false);
ser.serialize(aCas, sax2xml.getContentHandler());
} finally {
if (out != null) {
out.close();
}
}
}
代码示例来源:origin: org.apache.uima/uimaj-tools
OutputStream outStream = new BufferedOutputStream(new FileOutputStream(xcasFile));
XMLSerializer xmlSerializer = new XMLSerializer(outStream);
XCASSerializer xcasSerializer = new XCASSerializer(this.main.getCas().getTypeSystem());
xcasSerializer.serialize(this.main.getCas(), xmlSerializer.getContentHandler());
outStream.close();
代码示例来源:origin: apache/uima-uimaj
/**
* Serializes an XCAS to a stream.
*
* @param aCAS
* CAS to serialize.
* @param aStream
* output stream to which to write the XCAS XML document
* @param isFormattedOutput
* if true the XCAS will be serialized formatted
*
* @throws SAXException
* if a problem occurs during XCAS serialization
* @throws IOException
* if an I/O failure occurs
*/
public static void serialize(CAS aCAS, OutputStream aStream, boolean isFormattedOutput)
throws SAXException, IOException {
XCASSerializer xcasSerializer = new XCASSerializer(aCAS.getTypeSystem());
XMLSerializer sax2xml = new XMLSerializer(aStream, isFormattedOutput);
xcasSerializer.serialize(aCAS, sax2xml.getContentHandler());
}
代码示例来源:origin: org.apache.uima/uimaj-tools
XMLSerializer xmlSer = new XMLSerializer(outStream, false);
if (mXCAS.equalsIgnoreCase("xcas")) {
XCASSerializer ser = new XCASSerializer(aCAS.getTypeSystem());
ser.serialize(aCAS, xmlSer.getContentHandler());
代码示例来源:origin: org.apache.uima/uimaj-cpe
/**
* Convert CAS Container (aka CAS Object) to CAS Data
*
* @param aContainer
* CAS to convert
*
* @return CasData object containing all information from the CAS
*/
public CasData casContainerToCasData(CAS aContainer) {
// generate XCAS events and pipe them to XCasToCasDataSaxHandler
CasData result = new CasDataImpl();
XCasToCasDataSaxHandler handler = new XCasToCasDataSaxHandler(result);
XCASSerializer xcasSer = new XCASSerializer(aContainer.getTypeSystem());
xcasSer.setDocumentTypeName(this.getDocumentTextTypeName());
xcasSer.setDocumentTextFeature(this.getDocumentTextFeatureName());
try {
xcasSer.serialize(aContainer, handler);
} catch (IOException e) {
throw new UIMARuntimeException(e);
} catch (SAXException e) {
throw new UIMARuntimeException(e);
}
return result;
}
}
代码示例来源:origin: apache/uima-uimaj
try {
UIMAFramework.getLogger().log(Level.FINEST, "Serializing CAS.");
XCASSerializer xcasSerializer = new XCASSerializer(myCas.getTypeSystem(), this.uimaContext);
内容来源于网络,如有侵权,请联系作者删除!