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 <cmath>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
@ -236,14 +236,21 @@ float BleuScorer::calculateScore(const vector<int>& comps) const
|
|||||||
return exp(logbleu);
|
return exp(logbleu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleuScorer::dump_counts(const NgramCounts& counts) const {
|
void BleuScorer::dump_counts(ostream* os,
|
||||||
for (NgramCounts::const_iterator i = counts.begin();
|
const NgramCounts& counts) const {
|
||||||
i != counts.end(); ++i) {
|
for (NgramCounts::const_iterator it = counts.begin();
|
||||||
cerr << "(";
|
it != counts.end(); ++it) {
|
||||||
copy(i->first.begin(), i->first.end(), ostream_iterator<int>(cerr," "));
|
*os << "(";
|
||||||
cerr << ") " << i->second << ", ";
|
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,
|
void BleuScorer::CalcAverage(size_t sentence_id,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef MERT_BLEU_SCORER_H_
|
#ifndef MERT_BLEU_SCORER_H_
|
||||||
#define MERT_BLEU_SCORER_H_
|
#define MERT_BLEU_SCORER_H_
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
size_t countNgrams(const string& line, NgramCounts& counts, unsigned int n);
|
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.
|
// For calculating effective reference length.
|
||||||
void CalcAverage(size_t sentence_id,
|
void CalcAverage(size_t sentence_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user