2011-08-19 01:35:16 +04:00
|
|
|
#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:
|
2011-11-12 04:51:27 +04:00
|
|
|
explicit CderScorer(const string& config);
|
2011-08-19 01:35:16 +04:00
|
|
|
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;
|
2011-11-12 04:40:01 +04:00
|
|
|
}
|
2011-08-19 01:35:16 +04:00
|
|
|
|
|
|
|
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);
|
2011-11-12 04:24:19 +04:00
|
|
|
int distance(int word1, int word2) const
|
2011-08-19 01:35:16 +04:00
|
|
|
{
|
2011-11-12 04:24:19 +04:00
|
|
|
return word1 == word2 ? 0 : 1;
|
2011-08-19 01:35:16 +04:00
|
|
|
}
|
|
|
|
|
2011-11-12 04:24:19 +04:00
|
|
|
// no copying allowed
|
2011-08-19 01:35:16 +04:00
|
|
|
CderScorer(const CderScorer&);
|
2011-11-12 04:40:01 +04:00
|
|
|
~CderScorer() {}
|
2011-08-19 01:35:16 +04:00
|
|
|
CderScorer& operator=(const CderScorer&);
|
|
|
|
};
|
|
|
|
|
2011-11-12 02:59:50 +04:00
|
|
|
#endif // __CDERSCORER_H__
|