diff options
author | Barry Haddow <barry.haddow@gmail.com> | 2011-11-14 20:03:56 +0400 |
---|---|---|
committer | Barry Haddow <barry.haddow@gmail.com> | 2011-11-14 20:03:56 +0400 |
commit | 58268cc3dd4615d468a61aebc5831f6375abacfe (patch) | |
tree | d81ee435b6ffded160ca83c4f95ee5aa73cd1ed0 /mert | |
parent | 94f3c1ac8b91a1173adc1b2093e2867e5218349a (diff) |
Test for pro
Diffstat (limited to 'mert')
-rw-r--r-- | mert/Data.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mert/Data.cpp b/mert/Data.cpp index e4bef6707..0acfbeac3 100644 --- a/mert/Data.cpp +++ b/mert/Data.cpp @@ -170,9 +170,15 @@ public: void Data::sampleRankedPairs( const std::string &rankedpairfile ) { cout << "Sampling ranked pairs." << endl; - ofstream *outFile = new ofstream(); - outFile->open( rankedpairfile.c_str() ); - ostream *out = outFile; + ostream* out = NULL; + ofstream* outFile = NULL; + if (rankedpairfile == "stdout") { + out = &cout; + } else { + outFile = new ofstream(); + outFile->open( rankedpairfile.c_str() ); + out = outFile; + } const unsigned int n_samplings = 5000; const unsigned int n_samples = 50; @@ -225,7 +231,10 @@ void Data::sampleRankedPairs( const std::string &rankedpairfile ) { //cerr << "collected " << collected << endl; } out->flush(); - outFile->close(); + if (outFile) { + outFile->close(); + delete outFile; + } } void Data::outputSample( ostream &out, const FeatureStats &f1, const FeatureStats &f2 ) |