mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-11-10 00:47:31 +03:00
Simple refactoring of BLEU scorer.
This commit is contained in:
parent
43beb88df5
commit
d776281b8b
@ -195,3 +195,12 @@ float BleuScorer::calculateScore(const vector<int>& comps)
|
||||
//cerr << " " << exp(logbleu) << endl;
|
||||
return exp(logbleu);
|
||||
}
|
||||
|
||||
void BleuScorer::dump_counts(counts_t& counts) {
|
||||
for (counts_it i = counts.begin(); i != counts.end(); ++i) {
|
||||
cerr << "(";
|
||||
copy(i->first.begin(), i->first.end(), ostream_iterator<int>(cerr," "));
|
||||
cerr << ") " << i->second << ", ";
|
||||
}
|
||||
cerr << endl;
|
||||
}
|
||||
|
@ -34,22 +34,15 @@ public:
|
||||
virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry);
|
||||
|
||||
size_t NumberOfScores() {
|
||||
// cerr << "BleuScorer: " << (2 * LENGTH + 1) << endl;
|
||||
return (2 * kLENGTH + 1);
|
||||
}
|
||||
|
||||
|
||||
//protected:
|
||||
float calculateScore(const vector<int>& comps);
|
||||
|
||||
private:
|
||||
// no copying allowed
|
||||
BleuScorer(const BleuScorer&);
|
||||
BleuScorer& operator=(const BleuScorer&);
|
||||
|
||||
//Used to construct the ngram map
|
||||
struct CompareNgrams {
|
||||
int operator() (const vector<int>& a, const vector<int>& b) {
|
||||
int operator()(const vector<int>& a, const vector<int>& b) {
|
||||
size_t i;
|
||||
size_t as = a.size();
|
||||
size_t bs = b.size();
|
||||
@ -70,7 +63,6 @@ private:
|
||||
|
||||
typedef map<vector<int>,int,CompareNgrams> counts_t;
|
||||
typedef map<vector<int>,int,CompareNgrams>::iterator counts_it;
|
||||
|
||||
typedef ScopedVector<counts_t> refcounts_t;
|
||||
|
||||
/**
|
||||
@ -78,14 +70,7 @@ private:
|
||||
*/
|
||||
size_t countNgrams(const string& line, counts_t& counts, unsigned int n);
|
||||
|
||||
void dump_counts(counts_t& counts) {
|
||||
for (counts_it i = counts.begin(); i != counts.end(); ++i) {
|
||||
cerr << "(";
|
||||
copy(i->first.begin(), i->first.end(), ostream_iterator<int>(cerr," "));
|
||||
cerr << ") " << i->second << ", ";
|
||||
}
|
||||
cerr << endl;
|
||||
}
|
||||
void dump_counts(counts_t& counts);
|
||||
|
||||
const int kLENGTH;
|
||||
BleuReferenceLengthStrategy _refLengthStrategy;
|
||||
@ -93,6 +78,10 @@ private:
|
||||
// data extracted from reference files
|
||||
refcounts_t _refcounts;
|
||||
vector<vector<size_t> > _reflengths;
|
||||
|
||||
// no copying allowed
|
||||
BleuScorer(const BleuScorer&);
|
||||
BleuScorer& operator=(const BleuScorer&);
|
||||
};
|
||||
|
||||
#endif // __BLEUSCORER_H__
|
||||
|
Loading…
Reference in New Issue
Block a user