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 #include #include -#include +#include #include #include "Util.h" @@ -236,14 +236,21 @@ float BleuScorer::calculateScore(const vector& 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(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, diff --git a/mert/BleuScorer.h b/mert/BleuScorer.h index 6c1660fab..7ae19fa5f 100644 --- a/mert/BleuScorer.h +++ b/mert/BleuScorer.h @@ -1,7 +1,7 @@ #ifndef MERT_BLEU_SCORER_H_ #define MERT_BLEU_SCORER_H_ -#include +#include #include #include @@ -45,7 +45,7 @@ private: */ size_t countNgrams(const string& line, NgramCounts& counts, unsigned int n); - void dump_counts(const NgramCounts& counts) const; + void dump_counts(std::ostream* os, const NgramCounts& counts) const; // For calculating effective reference length. void CalcAverage(size_t sentence_id,