diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-02-25 21:01:03 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-02-25 21:01:03 +0400 |
commit | 669b9d9c7aab3553df561b4b6e1f1328669d5ef2 (patch) | |
tree | bd7041b181a366160aa2f48c22655582954e613b /mert/BleuScorer.cpp | |
parent | 8e0a61d0d731bc1e2a4f427d48a5a26ff8f7c923 (diff) |
Minor change the logging utility for n-gram counts.
Use std::ostream instead of directly using std::cerr.
Diffstat (limited to 'mert/BleuScorer.cpp')
-rw-r--r-- | mert/BleuScorer.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/mert/BleuScorer.cpp b/mert/BleuScorer.cpp index d8f14c366..efa189aa1 100644 --- a/mert/BleuScorer.cpp +++ b/mert/BleuScorer.cpp @@ -4,7 +4,7 @@ #include <cmath> #include <climits> #include <fstream> -#include <iterator> +#include <iostream> #include <stdexcept> #include "Util.h" @@ -236,14 +236,21 @@ float BleuScorer::calculateScore(const vector<int>& comps) const return exp(logbleu); } -void BleuScorer::dump_counts(const NgramCounts& counts) const { - for (NgramCounts::const_iterator i = counts.begin(); - i != counts.end(); ++i) { - cerr << "("; - copy(i->first.begin(), i->first.end(), ostream_iterator<int>(cerr," ")); - cerr << ") " << i->second << ", "; +void BleuScorer::dump_counts(ostream* os, + const NgramCounts& counts) const { + for (NgramCounts::const_iterator it = counts.begin(); + it != counts.end(); ++it) { + *os << "("; + const NgramCounts::Key& keys = it->first; + for (size_t i = 0; i < keys.size(); ++i) { + if (i != 0) { + *os << " "; + } + *os << keys[i]; + } + *os << ") : " << it->second << ", "; } - cerr << endl; + *os << endl; } void BleuScorer::CalcAverage(size_t sentence_id, |