org.apache.uima.cas.impl.XCASDeserializer.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.apache.uima.cas.impl.XCASDeserializer.<init>()方法的一些代码示例,展示了XCASDeserializer.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XCASDeserializer.<init>()方法的具体详情如下:
包路径:org.apache.uima.cas.impl.XCASDeserializer
类名称:XCASDeserializer
方法名:<init>

XCASDeserializer.<init>介绍

[英]Create a new deserializer from a type system. Note: all CAS arguments later supplied to getXCASHandler() must have this type system as their type system.
[中]从类型系统创建新的反序列化程序。注意:以后提供给getXCASHandler()的所有CAS参数必须将此类型系统作为其类型系统。

代码示例

代码示例来源:origin: apache/uima-uimaj

XCASDeserializer deser = new XCASDeserializer(myCas.getTypeSystem(), this.uimaContext);
deser.setDocumentTypeName("Detag:DetagContent");
if (!ignoreResponse) {

代码示例来源:origin: apache/uima-uimaj

/**
 * Deserializes an XCAS from a stream.
 * 
 * @param aStream
 *          input stream from which to read the XCAS XML document
 * @param aCAS
 *          CAS into which to deserialize. This CAS must be set up with a type system that is
 *          compatible with that in the XCAS.
 * @param aLenient
 *          if true, unknown Types will be ignored. If false, unknown Types will cause an
 *          exception. The default is false.
 * 
 * @throws SAXException
 *           if an XML Parsing error occurs
 * @throws IOException
 *           if an I/O failure occurs
 */
public static void deserialize(InputStream aStream, CAS aCAS, boolean aLenient)
    throws SAXException, IOException {
 XMLReader xmlReader = XMLUtils.createXMLReader();
 XCASDeserializer deser = new XCASDeserializer(aCAS.getTypeSystem());
 ContentHandler handler;
 if (aLenient) {
  handler = deser.getXCASHandler(aCAS, new OutOfTypeSystemData());
 } else {
  handler = deser.getXCASHandler(aCAS);
 }
 xmlReader.setContentHandler(handler);
 xmlReader.parse(new InputSource(aStream));
}

代码示例来源:origin: apache/uima-uimaj

public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException {
 if (mDelegateHandler == null) {
  // try to find out whether we should use the XCAS or XMI deserializers
  // if there's an xmi:version attribute, always use XMI
  String xmiVer = attributes.getValue("xmi:version");
  if (xmiVer != null && xmiVer.length() > 0) {
   XmiCasDeserializer deser = new XmiCasDeserializer(mCAS.getTypeSystem());
   mDelegateHandler = deser.getXmiCasHandler(mCAS, mLenient);
  } else if ("CAS".equals(localName)) // use XCAS
  {
   XCASDeserializer deser = new XCASDeserializer(mCAS.getTypeSystem());
   mDelegateHandler = deser
       .getXCASHandler(mCAS, mLenient ? new OutOfTypeSystemData() : null);
  } else // default to XMI
  {
   XmiCasDeserializer deser = new XmiCasDeserializer(mCAS.getTypeSystem());
   mDelegateHandler = deser.getXmiCasHandler(mCAS, mLenient);
  }
  mDelegateHandler.startDocument();
 }
 mDelegateHandler.startElement(uri, localName, qName, attributes);
}

代码示例来源:origin: org.apache.uima/uimaj-component-test-util

/**
* create a CAS object from the given XCAS and typesystem files.
*
* @param tsFile -
*           a typesystem file
* @param xcasFile -
*           a xcas file
* @return CAS - CAS object created from the given input data
* @throws Exception passthru
*/
public static CAS getCASfromXCAS(File tsFile, File xcasFile)
   throws Exception {
 try {
   Object tsDescriptor = UIMAFramework.getXMLParser().parse(
      new XMLInputSource(tsFile));
   TypeSystemDescription tsDesc = (TypeSystemDescription) tsDescriptor;
   CAS cas = CasCreationUtils.createCas(tsDesc, null,
      new FsIndexDescription[0]);
   SAXParser parser = XMLUtils.createSAXParserFactory().newSAXParser();
   XCASDeserializer xcasDeserializer = new XCASDeserializer(cas
      .getTypeSystem());
   parser.parse(xcasFile, xcasDeserializer.getXCASHandler(cas));
   return cas;
 } catch (Exception ex) {
   JUnitExtension.handleException(ex);
 }
 return null;
}

代码示例来源:origin: apache/uima-uimaj

/**
* create a CAS object from the given XCAS and typesystem files
* 
* @param tsFile -
*           a typesystem file
* @param xcasFile -
*           a xcas file
* 
* @return CAS - CAS object created from the given input data
* @throws Exception passthru
*/
public static CAS getCASfromXCAS(File tsFile, File xcasFile)
   throws Exception {
 try {
   Object tsDescriptor = UIMAFramework.getXMLParser().parse(
      new XMLInputSource(tsFile));
   TypeSystemDescription tsDesc = (TypeSystemDescription) tsDescriptor;
   CAS cas = CasCreationUtils.createCas(tsDesc, null,
      new FsIndexDescription[0]);
   SAXParser parser = XMLUtils.createSAXParserFactory().newSAXParser();
   XCASDeserializer xcasDeserializer = new XCASDeserializer(cas
      .getTypeSystem());
   parser.parse(xcasFile, xcasDeserializer.getXCASHandler(cas));
   return cas;
 } catch (Exception ex) {
   JUnitExtension.handleException(ex);
 }
 return null;
}

代码示例来源:origin: org.apache.uima/uimaj-tools

SAXParserFactory saxParserFactory = XMLUtils.createSAXParserFactory();
SAXParser parser = saxParserFactory.newSAXParser();
XCASDeserializer xcasDeserializer = new XCASDeserializer(this.main.getCas()
  .getTypeSystem());
this.main.getCas().reset();

代码示例来源:origin: org.apache.uima/uimaj-cpe

generator.setDocumentTextTypeName(this.getDocumentTextTypeName());
generator.setDocumentTextFeatureName(this.getDocumentTextFeatureName());
XCASDeserializer xcasDeser = new XCASDeserializer(aContainer.getTypeSystem());
xcasDeser.setDocumentTypeName(this.getDocumentTextTypeName());

相关文章