diff options
author | machacekmatous <machacekmatous@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-08-19 01:35:16 +0400 |
---|---|---|
committer | machacekmatous <machacekmatous@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-08-19 01:35:16 +0400 |
commit | 63fd490a51be2faf34d6d6ef4ef8104b78814e6e (patch) | |
tree | 1ff043b0846aac057591917fed978983d5212fc4 /mert/CderScorer.h | |
parent | 96417949c2f3d85b535e81c1d1358752b93c00be (diff) |
Added CDER metric to use in MERT.
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4152 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/CderScorer.h')
-rw-r--r-- | mert/CderScorer.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/mert/CderScorer.h b/mert/CderScorer.h new file mode 100644 index 000000000..1a2989b9e --- /dev/null +++ b/mert/CderScorer.h @@ -0,0 +1,59 @@ +#ifndef __CDERSCORER_H__ +#define __CDERSCORER_H__ + +#include <algorithm> +#include <iostream> +#include <string> +#include <vector> +#include "Types.h" +#include "ScoreData.h" +#include "Scorer.h" + + +using namespace std; + + +class CderScorer: public StatisticsBasedScorer +{ +public: + CderScorer(const string& config); + 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 prepareStatsVector(size_t sid, const string& text, vector<int>& stats); + + size_t NumberOfScores() { + return 2; + }; + + float calculateScore(const vector<int>& comps); + +private: + typedef vector<int> sent_t; + vector<vector<sent_t> > ref_sentences; + + vector<int> computeCD(const sent_t& cand, const sent_t& ref); + int distance(int word1, int word2) + { + if (word1 == word2) + return 0; + else + return 1; + } + + //no copy + CderScorer(const CderScorer&); + ~CderScorer() {}; + CderScorer& operator=(const CderScorer&); +}; + + +#endif |