Package org.apache.ctakes.ytex.uima.model

Examples of org.apache.ctakes.ytex.uima.model.Document


    });
  }

  private Document createDocument(JCas jcas, String analysisBatch,
      boolean bStoreDocText, boolean bStoreCAS) {
    Document doc = new Document();
    if (bStoreDocText)
      doc.setDocText(jcas.getDocumentText());
    doc.setAnalysisBatch(analysisBatch == null
        || analysisBatch.length() == 0 ? getDefaultAnalysisBatch()
        : analysisBatch);
    // look for the ctakes DocumentID anno
    if (setUimaDocId(jcas, doc,
        "edu.mayo.bmi.uima.core.type.structured.DocumentID",
        "documentID") == null) {
      // look for the uima SourceDocumentInformation anno
      setUimaDocId(jcas, doc,
          "org.apache.uima.examples.SourceDocumentInformation", "uri");
    }
    // look for document
    if (bStoreCAS) {
      try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream zipOut = new GZIPOutputStream(out);
        XmiCasSerializer ser = new XmiCasSerializer(
            jcas.getTypeSystem());
        XMLSerializer xmlSer = new XMLSerializer(zipOut, false);
        ser.serialize(jcas.getCas(), xmlSer.getContentHandler());
        zipOut.close();
        doc.setCas(out.toByteArray());
      } catch (Exception saxException) {
        log.error("error serializing document cas", saxException);
      }
    }
    return doc;
View Full Code Here


    final int documentId = txTemplate
        .execute(new TransactionCallback<Integer>() {

          @Override
          public Integer doInTransaction(TransactionStatus arg0) {
            Document doc = createDocument(jcas, analysisBatch,
                bStoreDocText, bStoreCAS);
            sessionFactory.getCurrentSession().save(doc);
            // make sure the document has been saved
            getSessionFactory().getCurrentSession().flush();
            saveAnnotationsHib(jcas,
                bInsertAnnotationContainmentLinks,
                setTypesToIgnore, doc);
            extractAndSaveDocKey(jcas, doc);
            return doc.getDocumentID();
          }
        });
    if (log.isTraceEnabled())
      log.trace("end saveDocument");
    return documentId;
View Full Code Here

TOP

Related Classes of org.apache.ctakes.ytex.uima.model.Document

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.