Package org.apache.uima.util

Examples of org.apache.uima.util.XMLSerializer


  public void serialize(OutputStream out) throws CoreException {

    if (DocumentFormat.XCAS.equals(format)) {
      XCASSerializer xcasSerializer = new XCASSerializer(mCAS.getTypeSystem());

      XMLSerializer xmlSerialzer = new XMLSerializer(out, true);

      try {
        xcasSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
      } catch (IOException e) {
        String message = e.getMessage() != null ? e.getMessage() : "";

        IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);

        throw new CoreException(s);
      } catch (SAXException e) {
        String message = e.getMessage() != null ? e.getMessage() : "";

        IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);

        throw new CoreException(s);
      }
    } else if (DocumentFormat.XMI.equals(format)) {
      XmiCasSerializer xmiSerializer = new XmiCasSerializer(mCAS.getTypeSystem());

      XMLSerializer xmlSerialzer = new XMLSerializer(out, true);

      try {
        xmiSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
      } catch (SAXException e) {
        String message = e.getMessage() != null ? e.getMessage() : "";

        IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
View Full Code Here


  public static String getXCASasString(CasData aCasData, String[] keysToFilter) throws Exception {
    CasDataToXCas generator = new CasDataToXCas();
    generator.setTypesToFilter(keysToFilter);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLSerializer sax2xml = new XMLSerializer(baos);
    generator.setContentHandler(sax2xml.getContentHandler());

    generator.generateXCas(aCasData);

    return new String(baos.toByteArray());
  }
View Full Code Here

   *          - the stream to write the current <code>DotCorpus</code> instance.
   * @throws CoreException
   */
  public static void serialize(DotCorpus dotCorpus, OutputStream out) throws CoreException {

    XMLSerializer xmlSerializer = new XMLSerializer(out, true);
    ContentHandler xmlSerHandler = xmlSerializer.getContentHandler();

    try {
      xmlSerHandler.startDocument();
      xmlSerHandler.startElement("", CONFIG_ELEMENT, CONFIG_ELEMENT, new AttributesImpl());

View Full Code Here

      es.setLocalSofaData("this beer is good");

      // Test Multiple Sofas across XCAS serialization
      XCASSerializer ser = new XCASSerializer(this.cas.getTypeSystem());
      OutputStream outputXCAS = new FileOutputStream("Sofa.xcas");
      XMLSerializer xmlSer = new XMLSerializer(outputXCAS);
      try {
        ser.serialize(cas, xmlSer.getContentHandler());
        outputXCAS.close();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (SAXException e) {
        e.printStackTrace();
View Full Code Here

                    ". T M K A T M I B P T C I I L B .",
                    "... the more knowledge advance the more it become possible to condense it into little book . ");

    FileOutputStream out = new FileOutputStream("src/test/resources/data/docs/test.xcas");
    XCASSerializer ser = new XCASSerializer(jCas.getTypeSystem());
    XMLSerializer xmlSer = new XMLSerializer(out, false);
    ser.serialize(jCas.getCas(), xmlSer.getContentHandler());
    out.close();
  }
View Full Code Here

    tokenBuilder.buildTokens(jCas, text, "Me and all my friends are non - conformists .",
            "M A A M F A N - C .", "me and all my friend are non - conformist .");

    FileOutputStream out = new FileOutputStream("src/test/resources/data/docs/test.xmi");
    XmiCasSerializer ser = new XmiCasSerializer(jCas.getTypeSystem());
    XMLSerializer xmlSer = new XMLSerializer(out, false);
    ser.serialize(jCas.getCas(), xmlSer.getContentHandler());
    out.close();

  }
View Full Code Here

        String documentID = DocumentIDAnnotationUtil.getDocumentID(goldView);
        if (documentID == null) {
          throw new IllegalArgumentException("No documentID for CAS:\n" + jCas);
        }
         File outFile = new File(this.outputDirectory, documentID + ".xmi");
         ContentHandler handler = new XMLSerializer(new FileOutputStream(outFile)).getContentHandler();
        new XmiCasSerializer(jCas.getTypeSystem()).serialize(jCas.getCas(), handler);
      } catch (CASRuntimeException e) {
        throw new AnalysisEngineProcessException(e);
      } catch (SAXException e) {
        throw new AnalysisEngineProcessException(e);
View Full Code Here

  public static String getXCASasString(CasData aCasData, String[] keysToFilter) throws Exception {
    CasDataToXCas generator = new CasDataToXCas();
    generator.setTypesToFilter(keysToFilter);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLSerializer sax2xml = new XMLSerializer(baos);
    generator.setContentHandler(sax2xml.getContentHandler());

    generator.generateXCas(aCasData);

    return new String(baos.toByteArray());
  }
View Full Code Here

   *          - the stream to write the current <code>DotCorpus</code> instance.
   * @throws CoreException -
   */
  public static void serialize(DotCorpus dotCorpus, OutputStream out) throws CoreException {

    XMLSerializer xmlSerializer = new XMLSerializer(out, true);
    ContentHandler xmlSerHandler = xmlSerializer.getContentHandler();

    try {
      xmlSerHandler.startDocument();
      xmlSerHandler.startElement("", CONFIG_ELEMENT, CONFIG_ELEMENT, new AttributesImpl());

View Full Code Here

  public void serialize(OutputStream out) throws CoreException {

    if (DocumentFormat.XCAS.equals(format)) {
      XCASSerializer xcasSerializer = new XCASSerializer(mCAS.getTypeSystem());

      XMLSerializer xmlSerialzer = new XMLSerializer(out, true);

      try {
        xcasSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
      } catch (IOException e) {
        throwCoreException(e);
      } catch (SAXException e) {
        throwCoreException(e);
      }
    } else if (DocumentFormat.XMI.equals(format)) {
      XmiCasSerializer xmiSerializer = new XmiCasSerializer(mCAS.getTypeSystem());

      XMLSerializer xmlSerialzer = new XMLSerializer(out, true);

      try {
        xmiSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
      } catch (SAXException e) {
        throwCoreException(e);
      }
    } else {
      throw new CoreException(new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
View Full Code Here

TOP

Related Classes of org.apache.uima.util.XMLSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.