Пример #1
0
TyErrorId
AnnotatorDump::process(CAS & tcas,
                       const ResultSpecification &
                      ) {
  TyErrorId tyErrId;

  // in append mode all data in a session/collection is dumped into one file
  // otherwise the same dump file is deleted and rewritten for each document
  // in the session/collection
  if (!iv_bAppendFile) {
    tyErrId = openOutputFile();
    if (tyErrId != UIMA_ERR_NONE) {
      return tyErrId;
    }
  }

  assert(iv_clOutputStream.good());

  if (iv_bDumpDocBuffer) {
    //    Dumping the Document Buffer
    UnicodeStringRef doc = tcas.getDocumentText();

    outputDocBuffer(doc);
  }

  uima::CASWriterABase * writer = NULL;
  switch (iv_enOutputStyle) {
  case Xml:
    writer = new uima::XMLDumpWriter(tcas, iv_bDumpDocBuffer);
    break;
  case XCas:
    writer = new uima::XCASWriter(tcas, iv_bDumpDocBuffer);
    break;
  default:
    assert(false);
  }
  assert( EXISTS(writer) );
  auto_ptr<CASWriterABase> apWriter( writer );
  apWriter->write(iv_clOutputStream);

  // in append mode all data in a session/collection is dumped into one file
  // otherwise the same dump file is deleted and rewritten for each document
  // in the session/collection
  if (!iv_bAppendFile) {
    closeOutputFile();
  }

  return(TyErrorId)UIMA_ERR_NONE;
}