当前位置: 首页>>代码示例>>Java>>正文


Java XmiCasSerializer.serialize方法代码示例

本文整理汇总了Java中org.apache.uima.cas.impl.XmiCasSerializer.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java XmiCasSerializer.serialize方法的具体用法?Java XmiCasSerializer.serialize怎么用?Java XmiCasSerializer.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.cas.impl.XmiCasSerializer的用法示例。


在下文中一共展示了XmiCasSerializer.serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
  Type documentIdType = aCAS.getTypeSystem()
      .getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
  Feature docIdFeat = documentIdType.getFeatureByBaseName("documentId");

  String documentId = aCAS.getIndexRepository()
      .getAllIndexedFS(documentIdType)
      .get()
      .getStringValue(docIdFeat);

  if (documentId == null) {
    documentId = UUID.randomUUID().toString();
  }

  GridFSInputFile file = gridFS.createFile(documentId + ".xmi");

  try (OutputStream outputStream = file.getOutputStream()) {
    XmiCasSerializer.serialize(aCAS, outputStream);
  } catch (IOException | SAXException e) {
    throw new AnalysisEngineProcessException(e);
  }
}
 
开发者ID:nlpie,项目名称:biomedicus,代码行数:24,代码来源:MongoDbXmiWriter.java

示例2: writeXmi

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
/**
 * Serialize a CAS to a file in XMI format
 *
 * @param aCas CAS to serialize
 * @param name output file
 * @throws SAXException
 * @throws Exception
 * @throws ResourceProcessException
 */
private void writeXmi(CAS aCas, File name) throws IOException,
        SAXException {
    OutputStream out = null;

    try {
        // write XMI
        out = FileUtils.openOutputStream(name);
        // seems like it is not necessary to buffer outputStream for SAX TransformationHandler
        // out = new BufferedOutputStream(out);
        XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
        XMLSerializer xmlSer = new XMLSerializer(out, xmlFormatted);
        ser.serialize(aCas, xmlSer.getContentHandler());
    } finally {
        if (out != null) {
            out.close();
        }
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:28,代码来源:XmiWriter.java

示例3: run

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
private void run() throws ResourceInitializationException, IOException, SAXException {
    Collection<File> inputFiles =
            FileUtils.listFiles(inputDir, FileFilterUtils.suffixFileFilter(".xml"), null);
    if (inputFiles.isEmpty()) {
        return;
    }
    TypeSystemDescription tsd = TypeSystemDescriptionFactory
            .createTypeSystemDescription(typeSystemDescName);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    for (File inputFile : inputFiles) {
        AXMLReader.read(inputFile, cas);
        File outFile = getOutputFile(inputFile);
        OutputStream out = FileUtils.openOutputStream(outFile);
        try {
            XmiCasSerializer.serialize(cas, null, out, true, null);
        } finally {
            out.close();
            cas.reset();
        }
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:22,代码来源:AXML2XMI.java

示例4: process

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
    throws AnalysisEngineProcessException
{
    try (OutputStream docOS = getOutputStream(aJCas, ".xmi")) {
        XmiCasSerializer.serialize(aJCas.getCas(), null, docOS, prettyPrint, null);

        if (!typeSystemWritten || typeSystemFile == null) {
            writeTypeSystem(aJCas);
            typeSystemWritten = true;
        }
    }
    catch (Exception e) {
        throw new AnalysisEngineProcessException(e);
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:17,代码来源:XmiWriter.java

示例5: writeXmi

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
/**
 * Write xmi.
 *
 * @param aCas the a cas
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws SAXException the sAX exception
 */
private void writeXmi(CAS aCas) throws IOException, SAXException {
	if (outputFile == null) {
		outputFile = new File(outputFileName);
   		if(!outputFile.exists()) { outputFile.createNewFile(); }
   	}
	FileOutputStream out = null;
	try {
		out = new FileOutputStream(outputFile);
		XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
		XMLSerializer xmlSer = new XMLSerializer(out, true);
		ser.serialize(aCas, xmlSer.getContentHandler());
	}
	finally {
		if (out != null) { out.close(); }
	}
}
 
开发者ID:germanattanasio,项目名称:traceability-assistant,代码行数:24,代码来源:XCasWriter.java

示例6: serialize

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
private static void serialize(JCas jcas, File file) throws SAXException, IOException {
  OutputStream outputStream = null;
  try {
    outputStream = new BufferedOutputStream(new FileOutputStream(file));

    XmiCasSerializer xmiSerializer = new XmiCasSerializer(
        jcas.getTypeSystem());
    XMLSerializer xmlSerializer = new XMLSerializer(outputStream, true);
    xmiSerializer.serialize(jcas.getCas(),
        xmlSerializer.getContentHandler());

  } catch (FileNotFoundException fnfe) {
    throw new FileNotFoundException(fnfe.getMessage());
  } catch (SAXException saxe) {
    throw new SAXException(saxe.getMessage());
  } finally {
    try {
      outputStream.close();
    } catch (IOException ioe) {
      throw new IOException(ioe.getMessage());
    }
  }
}
 
开发者ID:giuseppetotaro,项目名称:ctakes-clinical-pipeline,代码行数:24,代码来源:CTAKESClinicalPipelineFactory.java

示例7: writeXmi

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
private void writeXmi(CAS aCas, String id) throws IOException, SAXException {
    File outFile = new File(outputDirectory, id + ".xmi");
    FileOutputStream out = null;

    try {
        out = new FileOutputStream(outFile);
        XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
        XMLSerializer xmlSer = new XMLSerializer(out, false);
        ser.serialize(aCas, xmlSer.getContentHandler());
    }
    finally {
        if (out != null) {
            out.close();
        }
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:17,代码来源:XWriter.java

示例8: writeXmi

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
/**
 * Serialize a CAS to a file in XMI format
 * 
 * @param aCas
 *          CAS to serialize
 * @param name
 *          output file
 * @throws SAXException
 * @throws Exception
 * 
 * @throws ResourceProcessException
 */
private void writeXmi(CAS aCas, File name, String modelFileName) throws IOException, SAXException {
  FileOutputStream out = null;

  try {
    // write XMI
    out = new FileOutputStream(name);
    XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
    XMLSerializer xmlSer = new XMLSerializer(out, false);
    ser.serialize(aCas, xmlSer.getContentHandler());
  } finally {
    if (out != null) {
      out.close();
    }
  }
}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:28,代码来源:XmiWriterCC.java

示例9: process

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
        throws AnalysisEngineProcessException
{
    try {
        java.io.ByteArrayOutputStream jCasOutputStream = new java.io.ByteArrayOutputStream();
        XmiCasSerializer.serialize(aJCas.getCas(), jCasOutputStream);

        // get name = id + .xmi
        String singleEntryName = DocumentMetaData.get(aJCas).getDocumentId() + ".xmi";
        // convert output stream to input stream
        //            InputStream inputStream = new ByteArrayInputStream(jCasOutputStream.toByteArray());

        // add to the tar
        addSingleEntryToTar(jCasOutputStream.toByteArray(), singleEntryName);

        if (!typeSystemWritten) {
            writeTypeSystem(aJCas);
            typeSystemWritten = true;
        }

        counter++;
    }
    catch (IOException | SAXException ex) {
        throw new AnalysisEngineProcessException(ex);
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:28,代码来源:CompressedXmiWriter.java

示例10: setJCas

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
public void setJCas(JCas jCas)
        throws IOException
{
    // now convert to XMI
    ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
    try {
        XmiCasSerializer.serialize(jCas.getCas(), byteOutputStream);
    }
    catch (SAXException e) {
        throw new IOException(e);
    }

    // encode to base64
    this.base64JCas = new BASE64Encoder().encode(byteOutputStream.toByteArray());
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:16,代码来源:StandaloneArgument.java

示例11: serializeCasToXmi

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
/**
 * Utility method that handles the XMI serialization
 * 
 * @param jcas
 *            the CAS that will be serialized
 * @param xmiFile
 *            the output file where the XMI will be stored
 * @throws IOException
 *             if there's an issue writing to the output file
 * @throws SAXException
 *             if there's an issue serializing the CAS
 */
private void serializeCasToXmi(JCas jcas, File xmiFile) throws IOException, SAXException {
	Writer writer = FileWriterUtil.initBufferedWriter(xmiFile, CharacterEncoding.UTF_8, WriteMode.OVERWRITE,
			FileSuffixEnforcement.OFF);
	try {
		XmiCasSerializer serializer = new XmiCasSerializer(jcas.getTypeSystem());
		XMLSerializer xmlSerializer = new XMLSerializer(writer, false);
		serializer.serialize(jcas.getCas(), xmlSerializer.getContentHandler());
	} finally {
		if (writer != null)
			writer.close();
	}

}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:26,代码来源:XmiPrinterAE.java

示例12: writeXmi

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
private void writeXmi(CAS aCas, OutputStream out) throws IOException,
        SAXException {
    // seems like it is not necessary to buffer outputStream for SAX TransformationHandler
    // out = new BufferedOutputStream(out);
    XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
    XMLSerializer xmlSer = new XMLSerializer(out, xmlFormatted);
    ser.serialize(aCas, xmlSer.getContentHandler());
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:9,代码来源:XmiWriterBase.java

示例13: serializeCAS

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
static private void serializeCAS(CAS cas, File outFile) throws IOException, SAXException {
    OutputStream out = null;
    try {
        out = FileUtils.openOutputStream(outFile);
        XmiCasSerializer xcs = new XmiCasSerializer(cas.getTypeSystem());
        XMLSerializer ser = new XMLSerializer(out, true);
        xcs.serialize(cas, ser.getContentHandler());
    } finally {
        IOUtils.closeQuietly(out);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:12,代码来源:XmiFileTreeCorpusDAO.java

示例14: call

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
@Override
public String call(String paragraph) throws Exception {

	this.jcas.setDocumentText(paragraph);
	
	// final AnalysisEngineDescription aed = getFastPipeline(); // Outputs
	// from default and fast pipelines are identical
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	SimplePipeline.runPipeline(this.jcas, this.aed);
	XmiCasSerializer xmiSerializer = new XmiCasSerializer(jcas.getTypeSystem());
	XMLSerializer xmlSerializer = new XMLSerializer(baos, true);
	xmiSerializer.serialize(jcas.getCas(),xmlSerializer.getContentHandler());
	this.jcas.reset();
	return baos.toString("utf-8");
}
 
开发者ID:selinachu,项目名称:SparkStreamingCTK,代码行数:16,代码来源:CtakesFunction.java

示例15: toXMICas

import org.apache.uima.cas.impl.XmiCasSerializer; //导入方法依赖的package包/类
public JCas toXMICas(JCas cas, Path filePath) {
	try {
		logger.debug("Exporting CAS to {}", filePath);
		XmiCasSerializer.serialize(cas.getCas(), new FileOutputStream(makeParentDirs(filePath).toFile()));
		logger.debug("XMI CAS export succeeded");
		return cas;
	} catch (FileNotFoundException | SAXException e) {
		throw new TermSuiteException(e);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:11,代码来源:PreprocessorService.java


注:本文中的org.apache.uima.cas.impl.XmiCasSerializer.serialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。