diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2011-11-12 05:58:14 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2011-11-12 05:58:14 +0400 |
commit | 54b3b846c7591c8e4b8443740e5f611297959ed7 (patch) | |
tree | 5a5ef4e3a7c8750ab474fafa60453904d576db47 | |
parent | 00b8c6d76895fb90ef4c8679f9337dafe9633019 (diff) |
Add const member functions in Scorer classes.
-rw-r--r-- | mert/BleuScorer.h | 2 | ||||
-rw-r--r-- | mert/CderScorer.cpp | 2 | ||||
-rw-r--r-- | mert/CderScorer.h | 4 | ||||
-rw-r--r-- | mert/MergeScorer.h | 3 | ||||
-rw-r--r-- | mert/PerScorer.h | 4 | ||||
-rw-r--r-- | mert/Scorer.cpp | 2 | ||||
-rw-r--r-- | mert/Scorer.h | 16 | ||||
-rw-r--r-- | mert/TerScorer.h | 7 |
8 files changed, 20 insertions, 20 deletions
diff --git a/mert/BleuScorer.h b/mert/BleuScorer.h index 97d0a6758..c5681ad55 100644 --- a/mert/BleuScorer.h +++ b/mert/BleuScorer.h @@ -34,7 +34,7 @@ public: virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry); virtual float calculateScore(const vector<int>& comps) const; - size_t NumberOfScores() const { + virtual size_t NumberOfScores() const { return 2 * kLENGTH + 1; } diff --git a/mert/CderScorer.cpp b/mert/CderScorer.cpp index 9ac38021b..e503eb7e5 100644 --- a/mert/CderScorer.cpp +++ b/mert/CderScorer.cpp @@ -55,7 +55,7 @@ float CderScorer::calculateScore(const vector<int>& comps) const return 1 - (comps[0] / (float) comps[1]); } -vector<int> CderScorer::computeCD(const sent_t& cand, const sent_t& ref) +vector<int> CderScorer::computeCD(const sent_t& cand, const sent_t& ref) const { int I = cand.size() + 1; // Number of inter-words positions in candidate sentence int L = ref.size() + 1; // Number of inter-words positions in reference sentence diff --git a/mert/CderScorer.h b/mert/CderScorer.h index a8d908374..802690a99 100644 --- a/mert/CderScorer.h +++ b/mert/CderScorer.h @@ -30,7 +30,7 @@ public: } virtual void prepareStatsVector(size_t sid, const string& text, vector<int>& stats); - size_t NumberOfScores() { + virtual size_t NumberOfScores() const { return 2; } @@ -40,7 +40,7 @@ private: typedef vector<int> sent_t; vector<vector<sent_t> > ref_sentences; - vector<int> computeCD(const sent_t& cand, const sent_t& ref); + vector<int> computeCD(const sent_t& cand, const sent_t& ref) const; int distance(int word1, int word2) const { return word1 == word2 ? 0 : 1; diff --git a/mert/MergeScorer.h b/mert/MergeScorer.h index e876986d1..67b4b5e48 100644 --- a/mert/MergeScorer.h +++ b/mert/MergeScorer.h @@ -37,8 +37,7 @@ public: virtual void setReferenceFiles(const vector<string>& referenceFiles); virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry); - virtual void whoami() const - { + virtual void whoami() const { cerr << "I AM MergeScorer" << std::endl; } diff --git a/mert/PerScorer.h b/mert/PerScorer.h index 744cb02fe..f8d0fa59c 100644 --- a/mert/PerScorer.h +++ b/mert/PerScorer.h @@ -32,11 +32,11 @@ public: virtual void setReferenceFiles(const vector<string>& referenceFiles); virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry); - virtual void whoami() { + virtual void whoami() const { cerr << "I AM PerScorer" << std::endl; } - size_t NumberOfScores() { + virtual size_t NumberOfScores() const { // cerr << "PerScorer: 3" << endl; return 3; } diff --git a/mert/Scorer.cpp b/mert/Scorer.cpp index 02c15c79b..0ba90ba60 100644 --- a/mert/Scorer.cpp +++ b/mert/Scorer.cpp @@ -86,7 +86,7 @@ StatisticsBasedScorer::StatisticsBasedScorer(const string& name, const string& c } void StatisticsBasedScorer::score(const candidates_t& candidates, const diffs_t& diffs, - statscores_t& scores) + statscores_t& scores) const { if (!_scoreData) { throw runtime_error("Score data not loaded"); diff --git a/mert/Scorer.h b/mert/Scorer.h index 903ec06ae..801f40d98 100644 --- a/mert/Scorer.h +++ b/mert/Scorer.h @@ -38,7 +38,7 @@ public: /** * Return the number of statistics needed for the computation of the score. */ - virtual size_t NumberOfScores() { + virtual size_t NumberOfScores() const { cerr << "Scorer: 0" << endl; return 0; } @@ -69,7 +69,7 @@ public: * applying each in turn, and calculating a new score each time. */ virtual void score(const candidates_t& candidates, const diffs_t& diffs, - statscores_t& scores) { + statscores_t& scores) const { //dummy impl if (!_scoreData) { throw runtime_error("score data not loaded"); @@ -84,7 +84,7 @@ public: * Calculate the score of the sentences corresponding to the list of candidate * indices. Each index indicates the 1-best choice from the n-best list. */ - float score(const candidates_t& candidates) { + float score(const candidates_t& candidates) const { diffs_t diffs; statscores_t scores; score(candidates, diffs, scores); @@ -95,7 +95,7 @@ public: return _name; } - size_t getReferenceSize() { + size_t getReferenceSize() const { if (_scoreData) { return _scoreData->size(); } @@ -121,9 +121,9 @@ protected: /** * Get value of config variable. If not provided, return default. */ - string getConfig(const string& key, const string& def="") { - map<string,string>::iterator i = _config.find(key); - if (i == _config.end()) { + string getConfig(const string& key, const string& def="") const { + map<string,string>::const_iterator i = _config.find(key); + if (i == _config.end()) { return def; } else { return i->second; @@ -175,7 +175,7 @@ public: StatisticsBasedScorer(const string& name, const string& config); virtual ~StatisticsBasedScorer() {} virtual void score(const candidates_t& candidates, const diffs_t& diffs, - statscores_t& scores); + statscores_t& scores) const; protected: /** diff --git a/mert/TerScorer.h b/mert/TerScorer.h index fb134a8de..411d942bf 100644 --- a/mert/TerScorer.h +++ b/mert/TerScorer.h @@ -35,12 +35,13 @@ public: virtual void setReferenceFiles(const vector<string>& referenceFiles); virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry); - virtual void whoami() { + virtual void whoami() const { cerr << "I AM TerScorer" << std::endl; } - size_t NumberOfScores() { + + virtual size_t NumberOfScores() const { // cerr << "TerScorer: " << (LENGTH + 1) << endl; - return (kLENGTH + 1); + return kLENGTH + 1; } virtual float calculateScore(const vector<int>& comps) const; |