Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-27 09:30:37 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-27 09:30:37 +0400
commit5e74e87da029f7bf1dba76fbcddb0842f1e72ee6 (patch)
tree7af8a09e3a2d8b46c2e65e31a6f646f1591518a7 /mert/InterpolatedScorer.h
parent04a717be2b4cffebb5b38d0af7303bfbfeb9d1ee (diff)
Fix memory leaks.
- The Scorer and ScoreData objects allocated by the new operator are now released using the ScopedVector class. - Add 'virtual' to inherited functions from the Scorer class.
Diffstat (limited to 'mert/InterpolatedScorer.h')
-rw-r--r--mert/InterpolatedScorer.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/mert/InterpolatedScorer.h b/mert/InterpolatedScorer.h
index 5d1f962c5..d8eb87e3f 100644
--- a/mert/InterpolatedScorer.h
+++ b/mert/InterpolatedScorer.h
@@ -14,25 +14,27 @@
#include "Types.h"
#include "ScoreData.h"
#include "Scorer.h"
+#include "ScopedVector.h"
/**
* Class that includes other scorers eg.
* Interpolated HAMMING and BLEU scorer **/
class InterpolatedScorer : public Scorer
{
-
public:
// name would be: "HAMMING,BLEU" or similar
InterpolatedScorer(const string& name, const string& config);
- virtual ~InterpolatedScorer() {};
+ virtual ~InterpolatedScorer() {}
+
virtual void score(const candidates_t& candidates, const diffs_t& diffs,
- statscores_t& scores) const;
+ statscores_t& scores) const;
+
+ virtual void setReferenceFiles(const vector<string>& referenceFiles);
+ virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry);
- void setReferenceFiles(const vector<string>& referenceFiles);
- void prepareStats(size_t sid, const string& text, ScoreStats& entry);
virtual size_t NumberOfScores() const {
size_t sz=0;
- for (vector<Scorer*>::const_iterator itsc = _scorers.begin(); itsc < _scorers.end(); itsc++) {
+ for (ScopedVector<Scorer>::const_iterator itsc = _scorers.begin(); itsc != _scorers.end(); itsc++) {
sz += (*itsc)->NumberOfScores();
}
return sz;
@@ -41,7 +43,12 @@ public:
virtual void setScoreData(ScoreData* data);
protected:
- vector<Scorer*> _scorers;
+ ScopedVector<Scorer> _scorers;
+
+ // Take the ownership of the heap-allocated the objects
+ // by Scorer objects.
+ ScopedVector<ScoreData> m_scorers_score_data;
+
vector<float> _scorerWeights;
};