mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Move funcions defined in a header into .cpp file.
This commit is contained in:
parent
b2987337d8
commit
905f959d83
@ -1,7 +1,17 @@
|
||||
#include "CderScorer.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
|
||||
inline int CalcDistance(int word1, int word2) {
|
||||
return word1 == word2 ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CderScorer::CderScorer(const string& config)
|
||||
: StatisticsBasedScorer("CDER",config) {}
|
||||
|
||||
@ -28,6 +38,17 @@ void CderScorer::setReferenceFiles(const vector<string>& referenceFiles)
|
||||
}
|
||||
}
|
||||
|
||||
void CderScorer::prepareStats(size_t sid, const string& text, ScoreStats& entry)
|
||||
{
|
||||
vector<int> stats;
|
||||
prepareStatsVector(sid, text, stats);
|
||||
|
||||
stringstream sout;
|
||||
copy(stats.begin(), stats.end(), ostream_iterator<float>(sout," "));
|
||||
string stats_str = sout.str();
|
||||
entry.set(stats_str);
|
||||
}
|
||||
|
||||
void CderScorer::prepareStatsVector(size_t sid, const string& text, vector<int>& stats)
|
||||
{
|
||||
sent_t cand;
|
||||
@ -75,7 +96,7 @@ vector<int> CderScorer::computeCD(const sent_t& cand, const sent_t& ref) const
|
||||
vector<int> possibleCosts;
|
||||
if (i > 0) {
|
||||
possibleCosts.push_back((*nextRow)[i-1] + 1); // Deletion
|
||||
possibleCosts.push_back((*row)[i-1] + distance(ref[l-1], cand[i-1])); // Substitution/Identity
|
||||
possibleCosts.push_back((*row)[i-1] + CalcDistance(ref[l-1], cand[i-1])); // Substitution/Identity
|
||||
}
|
||||
possibleCosts.push_back((*row)[i] + 1); // Insertion
|
||||
(*nextRow)[i] = *min_element(possibleCosts.begin(), possibleCosts.end());
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Types.h"
|
||||
@ -18,16 +17,9 @@ public:
|
||||
~CderScorer();
|
||||
|
||||
virtual void setReferenceFiles(const vector<string>& referenceFiles);
|
||||
virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry)
|
||||
{
|
||||
vector<int> stats;
|
||||
prepareStatsVector(sid, text, stats);
|
||||
|
||||
stringstream sout;
|
||||
copy(stats.begin(),stats.end(),ostream_iterator<float>(sout," "));
|
||||
string stats_str = sout.str();
|
||||
entry.set(stats_str);
|
||||
}
|
||||
virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry);
|
||||
|
||||
virtual void prepareStatsVector(size_t sid, const string& text, vector<int>& stats);
|
||||
|
||||
virtual size_t NumberOfScores() const {
|
||||
@ -41,10 +33,6 @@ private:
|
||||
vector<vector<sent_t> > m_ref_sentences;
|
||||
|
||||
vector<int> computeCD(const sent_t& cand, const sent_t& ref) const;
|
||||
int distance(int word1, int word2) const
|
||||
{
|
||||
return word1 == word2 ? 0 : 1;
|
||||
}
|
||||
|
||||
// no copying allowed
|
||||
CderScorer(const CderScorer&);
|
||||
|
Loading…
Reference in New Issue
Block a user