mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
CderScorer compute both CDER and WER metric
This commit is contained in:
parent
0021ef661e
commit
933f25b3b2
@ -12,8 +12,9 @@ inline int CalcDistance(int word1, int word2) {
|
||||
|
||||
} // namespace
|
||||
|
||||
CderScorer::CderScorer(const string& config)
|
||||
: StatisticsBasedScorer("CDER",config) {}
|
||||
CderScorer::CderScorer(const string& config, bool longJumps)
|
||||
: StatisticsBasedScorer("CDER",config),
|
||||
longJumpsAllowed(longJumps) {}
|
||||
|
||||
CderScorer::~CderScorer() {}
|
||||
|
||||
@ -102,11 +103,13 @@ void CderScorer::computeCD(const sent_t& cand, const sent_t& ref,
|
||||
(*nextRow)[i] = *min_element(possibleCosts.begin(), possibleCosts.end());
|
||||
}
|
||||
|
||||
// Cost of LongJumps is the same for all in the row
|
||||
int LJ = 1 + *min_element(nextRow->begin(), nextRow->end());
|
||||
|
||||
for (int i = 0; i < I; ++i) {
|
||||
(*nextRow)[i] = min((*nextRow)[i], LJ); // LongJumps
|
||||
if (longJumpsAllowed) {
|
||||
// Cost of LongJumps is the same for all in the row
|
||||
int LJ = 1 + *min_element(nextRow->begin(), nextRow->end());
|
||||
|
||||
for (int i = 0; i < I; ++i) {
|
||||
(*nextRow)[i] = min((*nextRow)[i], LJ); // LongJumps
|
||||
}
|
||||
}
|
||||
|
||||
delete row;
|
||||
|
@ -10,7 +10,7 @@ using namespace std;
|
||||
|
||||
class CderScorer: public StatisticsBasedScorer {
|
||||
public:
|
||||
explicit CderScorer(const string& config);
|
||||
explicit CderScorer(const string& config, bool longJumps = true);
|
||||
~CderScorer();
|
||||
|
||||
virtual void setReferenceFiles(const vector<string>& referenceFiles);
|
||||
@ -24,6 +24,9 @@ class CderScorer: public StatisticsBasedScorer {
|
||||
virtual float calculateScore(const vector<int>& comps) const;
|
||||
|
||||
private:
|
||||
|
||||
bool longJumpsAllowed;
|
||||
|
||||
typedef vector<int> sent_t;
|
||||
vector<vector<sent_t> > m_ref_sentences;
|
||||
|
||||
|
@ -18,6 +18,7 @@ vector<string> ScorerFactory::getTypes() {
|
||||
types.push_back(string("PER"));
|
||||
types.push_back(string("TER"));
|
||||
types.push_back(string("CDER"));
|
||||
types.push_back(string("WER"));
|
||||
types.push_back(string("MERGE"));
|
||||
types.push_back(string("SEMPOS"));
|
||||
return types;
|
||||
@ -31,7 +32,10 @@ Scorer* ScorerFactory::getScorer(const string& type, const string& config) {
|
||||
} else if (type == "TER") {
|
||||
return new TerScorer(config);
|
||||
} else if (type == "CDER") {
|
||||
return new CderScorer(config);
|
||||
return new CderScorer(config, true);
|
||||
} else if (type == "WER") {
|
||||
// CderScorer can compute both CDER and WER metric
|
||||
return new CderScorer(config, false);
|
||||
} else if (type == "SEMPOS") {
|
||||
return new SemposScorer(config);
|
||||
} else if (type == "MERGE") {
|
||||
|
Loading…
Reference in New Issue
Block a user