You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2008/03/12 19:25:45 UTC
svn commit: r636441 - /incubator/uima/uimacpp/trunk/src/utils/runAECpp.cpp
Author: eae
Date: Wed Mar 12 11:25:35 2008
New Revision: 636441
URL: http://svn.apache.org/viewvc?rev=636441&view=rev
Log:
UIMA-881 apply Bhavani's patch
Modified:
incubator/uima/uimacpp/trunk/src/utils/runAECpp.cpp
Modified: incubator/uima/uimacpp/trunk/src/utils/runAECpp.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/utils/runAECpp.cpp?rev=636441&r1=636440&r2=636441&view=diff
==============================================================================
--- incubator/uima/uimacpp/trunk/src/utils/runAECpp.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/utils/runAECpp.cpp Wed Mar 12 11:25:35 2008
@@ -19,7 +19,7 @@
--------------------------------------------------------------------------
- Test driver that reads text files or XCASs and calls the annotator
+ Test driver that reads text files or XCASs or XMIs and calls the annotator
-------------------------------------------------------------------------- */
@@ -41,7 +41,7 @@
#include "uima/dirwalk.hpp"
#include "uima/api.hpp"
-#include "uima/xmlwriter.hpp"
+#include "uima/xmiwriter.hpp"
#include "uima/xcasdeserializer.hpp"
#include "uima/xmideserializer.hpp"
@@ -67,17 +67,17 @@
dataFormats xcasInput;
void process (AnalysisEngine * pEngine, CAS * cas, std::string in, std::string out);
-void writeXCAS (CAS & outCas, int num, std::string in, std::string outfn);
+void writeXmi (CAS & outCas, int num, std::string in, std::string outfn);
void tell() {
cerr << "Usage: runAECpp UimaCppDescriptor <-x> InputFileOrDir <OutputDir>" << endl
<< " <-s Sofa> <-l LogLevel>" << endl;
cerr << " UimaCppDescriptor Analysis Engine descriptor for a CPP annotator" << endl;
cerr << " InputFileOrDir Input file or directory of files to process" << endl;
- cerr << " OutputDir Existing directory for XCAS outputs (optional)" << endl;
+ cerr << " OutputDir Existing directory for Xmi outputs (optional)" << endl;
cerr << " Options:" << endl;
cerr << " -x [-xmi] Input(s) must be in XCAS [XMI] format (default is raw text)" << endl;
- cerr << " -s Sofa Name of a Sofa to process (input must be an XCAS)" << endl;
+ cerr << " -s Sofa Name of a Sofa to process (input must be an XCAS or XMI)" << endl;
cerr << " -l logLevel Set to 0, 1, or 2 for Message, Warning, or Error" << endl;
}
@@ -173,7 +173,7 @@
/* Get a new CAS */
CAS* cas = pEngine->newCAS();
- /* process input xcas */
+ /* process input */
util::DirectoryWalk dirwalker(in.c_str());
if (dirwalker.isValid()) {
cout << "runAECpp::processing all files in directory: " << in.c_str() << endl;
@@ -190,7 +190,7 @@
//reset the cas
cas->reset();
}
- //get the next xcas file in the directory
+ //get the next input file in the directory
dirwalker.setToNext();
}
} else {
@@ -304,7 +304,7 @@
if (!mySofa.isValid()) {
cerr << "runAECpp:" << endl
<< " Specified Sofa named " << sofaName
- << " not found in the XCAS file" << endl;
+ << " not found in the input file" << endl;
exit(99);
}
@@ -314,9 +314,9 @@
i++;
CAS & outCas = casIter.next();
- //write out xcas
+ //write out xmi
if (outfn.length() > 0) {
- writeXCAS(outCas, i, in, outfn);
+ writeXmi(outCas, i, in, outfn);
}
//release the CAS
@@ -333,9 +333,9 @@
while (casIter.hasNext()) {
i++;
CAS & outCas = casIter.next();
- //write out xcas
+ //write out xmi
if (outfn.length() > 0) {
- writeXCAS(outCas, i, in, outfn);
+ writeXmi(outCas, i, in, outfn);
}
//release CAS
@@ -352,17 +352,17 @@
outfn.append("/");
outfn.append(infile.getName());
- //open a file stream for output xcas
+ //open a file stream for output xmi
ofstream file;
file.open (outfn.c_str(), ios::out | ios::binary);
if ( !file ) {
- cerr << "runAECpp: Error opening output xcas: " << outfn.c_str() << endl;
+ cerr << "runAECpp: Error opening output xmi: " << outfn.c_str() << endl;
exit(99);
}
//serialize the input cas
- cout << "runAECpp: write out xcas " << outfn << endl;
- XCASWriter writer(*cas, true);
+ cout << "runAECpp: write out xmi " << outfn << endl;
+ XmiWriter writer(*cas, true);
writer.write(file);
file.close();
}
@@ -374,7 +374,7 @@
}
}
-void writeXCAS (CAS & outCas, int num, std::string in, std::string outfn) {
+void writeXmi (CAS & outCas, int num, std::string in, std::string outfn) {
util::Filename infile((TCHAR*) in.c_str());
std::string ofn;
@@ -386,21 +386,22 @@
s << num;
ofn.append(s.str());
- //open a file stream for output xcas
+ //open a file stream for output xmi
ofstream file;
file.open (ofn.c_str(), ios::out | ios::binary);
if ( !file ) {
- cerr << "Error opening output xcas: " << ofn.c_str() << endl;
+ cerr << "Error opening output xmi: " << ofn.c_str() << endl;
exit(99);
}
//serialize the cas
- cout << "write out xcas " << ofn << endl;
- XCASWriter writer(outCas, true);
+ cout << "write out xmi " << ofn << endl;
+ XmiWriter writer(outCas, true);
writer.write(file);
file.close();
}
/* <EOF> */
+