mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 05:55:02 +03:00
Minor change the logging utility for n-gram counts.
Use std::ostream instead of directly using std::cerr.
This commit is contained in:
parent
4a63846f82
commit
37c19feebd
@ -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 << " ";
|
||||
}
|
||||
cerr << endl;
|
||||
*os << keys[i];
|
||||
}
|
||||
*os << ") : " << it->second << ", ";
|
||||
}
|
||||
*os << endl;
|
||||
}
|
||||
|
||||
void BleuScorer::CalcAverage(size_t sentence_id,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef MERT_BLEU_SCORER_H_
|
||||
#define MERT_BLEU_SCORER_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user