diff options
author | Barry Haddow <barry.haddow@gmail.com> | 2011-11-16 20:26:01 +0400 |
---|---|---|
committer | Barry Haddow <barry.haddow@gmail.com> | 2011-11-16 20:26:01 +0400 |
commit | aeead91b54282b6fda42ae2f689c9bc5ab6457c5 (patch) | |
tree | 5a02b7312c96be98d0e05a390b2f8a814b8767a8 /mert | |
parent | 79de3c8699153aa759f584825f4f5a75e3f9c08c (diff) |
Output to file. Remove debug.
Diffstat (limited to 'mert')
-rw-r--r-- | mert/Data.cpp | 1 | ||||
-rw-r--r-- | mert/pro.cpp | 30 |
2 files changed, 23 insertions, 8 deletions
diff --git a/mert/Data.cpp b/mert/Data.cpp index 1fae0080b..0acfbeac3 100644 --- a/mert/Data.cpp +++ b/mert/Data.cpp @@ -196,7 +196,6 @@ void Data::sampleRankedPairs( const std::string &rankedpairfile ) { unsigned int translation2 = rand() % n_translations; float bleu2 = sentenceLevelBleuPlusOne(scoredata->get(S,translation2)); - cerr << "Sampled " << translation1 << " " << translation2 << endl; if (abs(bleu1-bleu2) < min_diff) continue; diff --git a/mert/pro.cpp b/mert/pro.cpp index a9bd8c134..aa92d4373 100644 --- a/mert/pro.cpp +++ b/mert/pro.cpp @@ -108,6 +108,7 @@ int main(int argc, char** argv) vector<string> scoreFiles; vector<string> featureFiles; int seed; + string outputFile; //TODO: options const unsigned int n_candidates = 5000; // Gamma, in Hopkins & May const unsigned int n_samples = 50; // Xi, in Hopkins & May @@ -119,6 +120,7 @@ int main(int argc, char** argv) ("scfile,S", po::value<vector<string> >(&scoreFiles), "Scorer data files") ("ffile,F", po::value<vector<string> > (&featureFiles), "Feature data files") ("random-seed,r", po::value<int>(&seed), "Seed for random number generation") + ("output-file,o", po::value<string>(&outputFile), "Output file") ; po::options_description cmdline_options; @@ -152,6 +154,19 @@ int main(int argc, char** argv) exit(1); } + ostream* out; + ofstream outFile; + if (!outputFile.empty() ) { + outFile.open(outputFile.c_str()); + if (!(outFile)) { + cerr << "Error: Failed to open " << outputFile << endl; + exit(1); + } + out = &outFile; + } else { + out = &cout; + } + vector<FeatureDataIterator> featureDataIters; vector<ScoreDataIterator> scoreDataIters; @@ -199,7 +214,6 @@ int main(int argc, char** argv) size_t rand2 = rand() % n_translations; pair<size_t,size_t> translation2 = hypotheses[rand2]; float bleu2 = sentenceLevelBleuPlusOne(scoreDataIters[translation2.first]->operator[](translation2.second)); - cerr << "Sampled " << translation1.second<< " " << translation2.second << endl; /* cerr << "t(" << translation1.first << "," << translation1.second << ") = " << bleu1 << @@ -227,14 +241,14 @@ int main(int argc, char** argv) size_t hypo_id1 = samples[i].getTranslation1().second; size_t file_id2 = samples[i].getTranslation2().first; size_t hypo_id2 = samples[i].getTranslation2().second; - cout << "1"; - outputSample(cout, featureDataIters[file_id1]->operator[](hypo_id1), + *out << "1"; + outputSample(*out, featureDataIters[file_id1]->operator[](hypo_id1), featureDataIters[file_id2]->operator[](hypo_id2)); - cout << endl; - cout << "0"; - outputSample(cout, featureDataIters[file_id2]->operator[](hypo_id2), + *out << endl; + *out << "0"; + outputSample(*out, featureDataIters[file_id2]->operator[](hypo_id2), featureDataIters[file_id1]->operator[](hypo_id1)); - cout << endl; + *out << endl; } //advance all iterators for (size_t i = 0; i < featureFiles.size(); ++i) { @@ -244,5 +258,7 @@ int main(int argc, char** argv) ++sentenceId; } + outFile.close(); + } |