});
}
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;