diff options
-rw-r--r-- | mert/BleuScorer.h | 4 | ||||
-rw-r--r-- | mert/CderScorer.h | 4 | ||||
-rw-r--r-- | mert/Data.h | 11 | ||||
-rw-r--r-- | mert/FeatureArray.cpp | 3 | ||||
-rw-r--r-- | mert/FeatureArray.h | 3 | ||||
-rw-r--r-- | mert/FeatureData.cpp | 2 | ||||
-rw-r--r-- | mert/FeatureData.h | 9 | ||||
-rw-r--r-- | mert/FeatureStats.cpp | 9 | ||||
-rw-r--r-- | mert/MergeScorer.h | 5 | ||||
-rw-r--r-- | mert/Optimizer.cpp | 16 | ||||
-rw-r--r-- | mert/Optimizer.h | 9 | ||||
-rw-r--r-- | mert/PerScorer.h | 6 | ||||
-rw-r--r-- | mert/Point.cpp | 14 | ||||
-rw-r--r-- | mert/Point.h | 11 | ||||
-rw-r--r-- | mert/ScoreArray.cpp | 3 | ||||
-rw-r--r-- | mert/ScoreArray.h | 8 | ||||
-rw-r--r-- | mert/ScoreData.cpp | 2 | ||||
-rw-r--r-- | mert/ScoreData.h | 8 | ||||
-rw-r--r-- | mert/ScoreStats.cpp | 9 | ||||
-rw-r--r-- | mert/Scorer.h | 9 | ||||
-rw-r--r-- | mert/TerScorer.h | 4 | ||||
-rw-r--r-- | mert/Util.cpp | 6 | ||||
-rw-r--r-- | mert/Util.h | 2 |
23 files changed, 75 insertions, 82 deletions
diff --git a/mert/BleuScorer.h b/mert/BleuScorer.h index 07868c68a..373325744 100644 --- a/mert/BleuScorer.h +++ b/mert/BleuScorer.h @@ -54,7 +54,7 @@ public: size_t NumberOfScores() { // cerr << "BleuScorer: " << (2 * LENGTH + 1) << endl; return (2 * LENGTH + 1); - }; + } //protected: @@ -63,7 +63,7 @@ public: private: //no copy BleuScorer(const BleuScorer&); - ~BleuScorer() {}; + ~BleuScorer() {} BleuScorer& operator=(const BleuScorer&); //Used to construct the ngram map struct CompareNgrams { diff --git a/mert/CderScorer.h b/mert/CderScorer.h index 3b8bea8cc..1f9d01b3f 100644 --- a/mert/CderScorer.h +++ b/mert/CderScorer.h @@ -30,7 +30,7 @@ public: size_t NumberOfScores() { return 2; - }; + } float calculateScore(const vector<int>& comps); @@ -46,7 +46,7 @@ private: // no copying allowed CderScorer(const CderScorer&); - ~CderScorer() {}; + ~CderScorer() {} CderScorer& operator=(const CderScorer&); }; diff --git a/mert/Data.h b/mert/Data.h index 4e6b9b2ab..7d2fa1504 100644 --- a/mert/Data.h +++ b/mert/Data.h @@ -44,10 +44,11 @@ public: ScoreData* getScoreData() { return scoredata; - }; + } + FeatureData* getFeatureData() { return featdata; - }; + } Scorer* getScorer() { return theScorer; @@ -89,15 +90,15 @@ public: inline bool existsFeatureNames() { return featdata->existsFeatureNames(); - }; + } inline std::string getFeatureName(size_t idx) { return featdata->getFeatureName(idx); - }; + } inline size_t getFeatureIndex(const std::string& name) { return featdata->getFeatureIndex(name); - }; + } void sampleRankedPairs( const std::string &rankedPairFile ); void outputSample( std::ostream &out, const FeatureStats &f1, const FeatureStats &f2 ); diff --git a/mert/FeatureArray.cpp b/mert/FeatureArray.cpp index 91785ec91..a06434a5a 100644 --- a/mert/FeatureArray.cpp +++ b/mert/FeatureArray.cpp @@ -11,8 +11,7 @@ #include "Util.h" -FeatureArray::FeatureArray(): idx(""), _sparse_flag(false) -{}; +FeatureArray::FeatureArray() : idx(""), _sparse_flag(false) {} void FeatureArray::savetxt(std::ofstream& outFile) { diff --git a/mert/FeatureArray.h b/mert/FeatureArray.h index 6fa403f8c..f17fd9ee2 100644 --- a/mert/FeatureArray.h +++ b/mert/FeatureArray.h @@ -39,8 +39,7 @@ private: public: FeatureArray(); - - ~FeatureArray() {}; + ~FeatureArray() {} inline void clear() { array_.clear(); diff --git a/mert/FeatureData.cpp b/mert/FeatureData.cpp index c1837aeee..227def589 100644 --- a/mert/FeatureData.cpp +++ b/mert/FeatureData.cpp @@ -14,7 +14,7 @@ static const float MIN_FLOAT=-1.0*numeric_limits<float>::max(); static const float MAX_FLOAT=numeric_limits<float>::max(); -FeatureData::FeatureData() {}; +FeatureData::FeatureData() {} void FeatureData::save(std::ofstream& outFile, bool bin) { diff --git a/mert/FeatureData.h b/mert/FeatureData.h index 59f28fe75..e0e6321a2 100644 --- a/mert/FeatureData.h +++ b/mert/FeatureData.h @@ -36,8 +36,7 @@ private: public: FeatureData(); - - ~FeatureData() {}; + ~FeatureData() {} inline void clear() { array_.clear(); @@ -119,19 +118,19 @@ public: bool existsFeatureNames() { return (idx2featname_.size() > 0)?true:false; - }; + } std::string getFeatureName(size_t idx) { if (idx >= idx2featname_.size()) throw runtime_error("Error: you required an too big index"); return idx2featname_[idx]; - }; + } size_t getFeatureIndex(const std::string& name) { if (featname2idx_.find(name)==featname2idx_.end()) throw runtime_error("Error: feature " + name +" is unknown"); return featname2idx_[name]; - }; + } void setFeatureMap(const std::string feat); }; diff --git a/mert/FeatureStats.cpp b/mert/FeatureStats.cpp index cf8ae57f8..570980c97 100644 --- a/mert/FeatureStats.cpp +++ b/mert/FeatureStats.cpp @@ -86,12 +86,12 @@ FeatureStats::FeatureStats() available_ = AVAILABLE_; entries_ = 0; array_ = new FeatureStatsType[available_]; -}; +} FeatureStats::~FeatureStats() { delete [] array_; -}; +} FeatureStats::FeatureStats(const FeatureStats &stats) { @@ -100,7 +100,7 @@ FeatureStats::FeatureStats(const FeatureStats &stats) array_ = new FeatureStatsType[available_]; memcpy(array_,stats.getArray(),featbytes_); map_ = stats.getSparse(); -}; +} FeatureStats::FeatureStats(const size_t size) { @@ -108,8 +108,7 @@ FeatureStats::FeatureStats(const size_t size) entries_ = size; array_ = new FeatureStatsType[available_]; memset(array_,0,featbytes_); -}; - +} FeatureStats::FeatureStats(std::string &theString) { diff --git a/mert/MergeScorer.h b/mert/MergeScorer.h index 1d7cb78c9..501c08a1b 100644 --- a/mert/MergeScorer.h +++ b/mert/MergeScorer.h @@ -47,9 +47,10 @@ protected: float calculateScore(const vector<int>& comps); private: - //no copying allowed + // no copying allowed MergeScorer(const MergeScorer&); - ~MergeScorer(){}; + ~MergeScorer() {} + MergeScorer& operator=(const MergeScorer&); string javaEnv; diff --git a/mert/Optimizer.cpp b/mert/Optimizer.cpp index 66bc27023..724f46ecf 100644 --- a/mert/Optimizer.cpp +++ b/mert/Optimizer.cpp @@ -37,7 +37,7 @@ void Optimizer::SetScorer(Scorer *_scorer) void Optimizer::SetFData(FeatureData *_FData) { FData = _FData; -}; +} Optimizer::Optimizer(unsigned Pd,vector<unsigned> i2O,vector<parameter_t> start, unsigned int nrandom):scorer(NULL),FData(NULL),number_of_random_directions(nrandom) { @@ -59,7 +59,7 @@ Optimizer::Optimizer(unsigned Pd,vector<unsigned> i2O,vector<parameter_t> start, Point::fixedweights[i]=start[i]; } } -}; +} Optimizer::~Optimizer() {} @@ -70,7 +70,7 @@ statscore_t Optimizer::GetStatScore(const Point& param)const //copy(bests.begin(),bests.end(),ostream_iterator<unsigned>(cerr," ")); statscore_t score = GetStatScore(bests); return score; -}; +} map<float,diff_t >::iterator AddThreshold(map<float,diff_t >& thresholdmap,float newt,pair<unsigned,unsigned> newdiff) { @@ -88,7 +88,7 @@ map<float,diff_t >::iterator AddThreshold(map<float,diff_t >& thresholdmap,float it=ins.first; } return it; -}; +} statscore_t Optimizer::LineOptimize(const Point& origin,const Point& direction,Point& bestpoint)const @@ -299,8 +299,7 @@ statscore_t Optimizer::LineOptimize(const Point& origin,const Point& direction,P bestpoint=direction*bestx+origin; bestpoint.score=bestscore; return bestscore; -}; - +} void Optimizer::Get1bests(const Point& P,vector<unsigned>& bests)const { @@ -360,8 +359,7 @@ vector<statscore_t> Optimizer::GetIncStatScore(vector<unsigned> thefirst,vector< scorer->score(thefirst,thediffs,theres); return theres; -}; - +} float SimpleOptimizer::eps=0.0001; @@ -502,7 +500,7 @@ OptimizerFactory::OptType OptimizerFactory::GetOType(string type) if(typenames[thetype]==type) break; return((OptType)thetype); -}; +} Optimizer* OptimizerFactory::BuildOptimizer(unsigned dim,vector<unsigned> i2o,vector<parameter_t> start,string type, unsigned int nrandom) { diff --git a/mert/Optimizer.h b/mert/Optimizer.h index b2834ebbe..c9330a5bd 100644 --- a/mert/Optimizer.h +++ b/mert/Optimizer.h @@ -54,7 +54,8 @@ public: */ statscore_t GetStatScore(const vector<unsigned>& nbests)const { return scorer->score(nbests); - }; + } + statscore_t GetStatScore(const Point& param)const; vector<statscore_t > GetIncStatScore(vector<unsigned> ref,vector<vector <pair<unsigned,unsigned> > >)const; @@ -75,7 +76,7 @@ class SimpleOptimizer: public Optimizer private: static float eps; public: - SimpleOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom):Optimizer(dim,i2O,start,nrandom) {}; + SimpleOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom): Optimizer(dim, i2O, start,nrandom) {} virtual statscore_t TrueRun(Point&)const; }; @@ -87,7 +88,7 @@ class RandomDirectionOptimizer: public Optimizer private: static float eps; public: - RandomDirectionOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom):Optimizer(dim,i2O,start,nrandom) {}; + RandomDirectionOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start,unsigned int nrandom): Optimizer(dim,i2O,start,nrandom) {} virtual statscore_t TrueRun(Point&)const; }; @@ -97,7 +98,7 @@ public: class RandomOptimizer: public Optimizer { public: - RandomOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start, unsigned int nrandom):Optimizer(dim,i2O,start,nrandom) {}; + RandomOptimizer(unsigned dim,vector<unsigned> i2O,vector<parameter_t> start, unsigned int nrandom): Optimizer(dim,i2O,start,nrandom) {} virtual statscore_t TrueRun(Point&)const; }; diff --git a/mert/PerScorer.h b/mert/PerScorer.h index 6f88f5667..ae01b1079 100644 --- a/mert/PerScorer.h +++ b/mert/PerScorer.h @@ -37,16 +37,16 @@ public: size_t NumberOfScores() { // cerr << "PerScorer: 3" << endl; return 3; - }; + } //protected: - virtual float calculateScore(const vector<int>& comps) ; + virtual float calculateScore(const vector<int>& comps); private: // no copying allowed PerScorer(const PerScorer&); - ~PerScorer() {}; + ~PerScorer() {} PerScorer& operator=(const PerScorer&); // data extracted from reference files diff --git a/mert/Point.cpp b/mert/Point.cpp index 90d36da5a..590225358 100644 --- a/mert/Point.cpp +++ b/mert/Point.cpp @@ -72,7 +72,7 @@ Point::Point(const vector<parameter_t>& init, m_max[i] = max[optindices[i]]; } } -}; +} double Point::operator*(const FeatureStats& F)const @@ -90,6 +90,7 @@ double Point::operator*(const FeatureStats& F)const } return prod; } + Point Point::operator+(const Point& p2)const { assert(p2.size()==size()); @@ -98,7 +99,7 @@ Point Point::operator+(const Point& p2)const Res[i]+=p2[i]; Res.score=numeric_limits<statscore_t>::max(); return Res; -}; +} void Point::operator+=(const Point& p2) { @@ -106,8 +107,7 @@ void Point::operator+=(const Point& p2) for(unsigned i=0; i<size(); i++) operator[](i)+=p2[i]; score=numeric_limits<statscore_t>::max(); -}; - +} Point Point::operator*(float l)const { @@ -116,7 +116,7 @@ Point Point::operator*(float l)const Res[i]*=l; Res.score=numeric_limits<statscore_t>::max(); return Res; -}; +} ostream& operator<<(ostream& o,const Point& P) { @@ -126,7 +126,7 @@ ostream& operator<<(ostream& o,const Point& P) o << w[i] << " "; // o << "=> " << P.GetScore(); return o; -}; +} vector<parameter_t> Point::GetAllWeights()const { @@ -141,7 +141,7 @@ vector<parameter_t> Point::GetAllWeights()const w[it->first]=it->second; } return w; -}; +} diff --git a/mert/Point.h b/mert/Point.h index c92a99714..bf1643b36 100644 --- a/mert/Point.h +++ b/mert/Point.h @@ -60,9 +60,9 @@ public: } static bool OptimizeAll() { return fixedweights.empty(); - }; + } statscore_t score; - Point():vector<parameter_t>(dim) {}; + Point():vector<parameter_t>(dim) {} Point(const vector<parameter_t>& init, const vector<parameter_t>& min, const vector<parameter_t>& max @@ -79,9 +79,8 @@ public: * Write the Whole featureweight to a stream (ie pdim float). */ friend ostream& operator<<(ostream& o,const Point& P); - void Normalize() { - NormalizeL2(); - }; + + void Normalize() { NormalizeL2(); } void NormalizeL2(); void NormalizeL1(); @@ -92,7 +91,7 @@ public: vector<parameter_t> GetAllWeights()const; statscore_t GetScore()const { return score; - }; + } }; #endif // POINT_H diff --git a/mert/ScoreArray.cpp b/mert/ScoreArray.cpp index 92824c818..271d388d8 100644 --- a/mert/ScoreArray.cpp +++ b/mert/ScoreArray.cpp @@ -10,8 +10,7 @@ #include "ScoreArray.h" #include "Util.h" -ScoreArray::ScoreArray(): idx("") -{}; +ScoreArray::ScoreArray() : idx("") {} void ScoreArray::savetxt(std::ofstream& outFile, const std::string& sctype) { diff --git a/mert/ScoreArray.h b/mert/ScoreArray.h index c12c39aef..05fb71c94 100644 --- a/mert/ScoreArray.h +++ b/mert/ScoreArray.h @@ -38,8 +38,7 @@ private: public: ScoreArray(); - - ~ScoreArray() {}; + ~ScoreArray() {} inline void clear() { array_.clear(); @@ -69,10 +68,11 @@ public: inline std::string name() const { return score_type; - }; + } + inline void name(std::string &sctype) { score_type = sctype; - }; + } inline size_t size() { return array_.size(); diff --git a/mert/ScoreData.cpp b/mert/ScoreData.cpp index d41cc6e35..141eb0883 100644 --- a/mert/ScoreData.cpp +++ b/mert/ScoreData.cpp @@ -20,7 +20,7 @@ ScoreData::ScoreData(Scorer& ptr): theScorer->setScoreData(this); number_of_scores = theScorer->NumberOfScores(); // TRACE_ERR("ScoreData: number_of_scores: " << number_of_scores << std::endl); -}; +} void ScoreData::save(std::ofstream& outFile, bool bin) { diff --git a/mert/ScoreData.h b/mert/ScoreData.h index e0c87cb2e..564242a47 100644 --- a/mert/ScoreData.h +++ b/mert/ScoreData.h @@ -34,8 +34,7 @@ private: public: ScoreData(Scorer& sc); - - ~ScoreData() {}; + ~ScoreData() {} inline void clear() { array_.clear(); @@ -67,10 +66,11 @@ public: inline std::string name() { return score_type; - }; + } + inline std::string name(std::string &sctype) { return score_type = sctype; - }; + } void add(ScoreArray& e); void add(const ScoreStats& e, const std::string& sent_idx); diff --git a/mert/ScoreStats.cpp b/mert/ScoreStats.cpp index 8f34d23ca..9598ee0a5 100644 --- a/mert/ScoreStats.cpp +++ b/mert/ScoreStats.cpp @@ -17,12 +17,12 @@ ScoreStats::ScoreStats() available_ = AVAILABLE_; entries_ = 0; array_ = new ScoreStatsType[available_]; -}; +} ScoreStats::~ScoreStats() { delete [] array_; -}; +} ScoreStats::ScoreStats(const ScoreStats &stats) { @@ -30,8 +30,7 @@ ScoreStats::ScoreStats(const ScoreStats &stats) entries_ = stats.size(); array_ = new ScoreStatsType[available_]; memcpy(array_,stats.getArray(),scorebytes_); -}; - +} ScoreStats::ScoreStats(const size_t size) { @@ -39,7 +38,7 @@ ScoreStats::ScoreStats(const size_t size) entries_ = size; array_ = new ScoreStatsType[available_]; memset(array_,0,scorebytes_); -}; +} ScoreStats::ScoreStats(std::string &theString) { diff --git a/mert/Scorer.h b/mert/Scorer.h index e30ae26f2..7e3851f28 100644 --- a/mert/Scorer.h +++ b/mert/Scorer.h @@ -52,10 +52,9 @@ public: _config[name] = value; start = end+1; } + } - }; - virtual ~Scorer() {}; - + virtual ~Scorer() {} /** * Return the number of statistics needed for the computation of the score. @@ -63,7 +62,7 @@ public: virtual size_t NumberOfScores() { cerr << "Scorer: 0" << endl; return 0; - }; + } /** * Set the reference files. This must be called before prepareStats(). @@ -232,7 +231,7 @@ public: // cerr << "Using case preservation: " << _preserveCase << endl; } - ~StatisticsBasedScorer() {}; + ~StatisticsBasedScorer() {} virtual void score(const candidates_t& candidates, const diffs_t& diffs, statscores_t& scores); diff --git a/mert/TerScorer.h b/mert/TerScorer.h index 8a1fcbff9..9b76d135f 100644 --- a/mert/TerScorer.h +++ b/mert/TerScorer.h @@ -39,7 +39,7 @@ public: size_t NumberOfScores() { // cerr << "TerScorer: " << (LENGTH + 1) << endl; return (LENGTH + 1); - }; + } //protected: @@ -51,7 +51,7 @@ private: string tercomEnv; // no copying allowed TerScorer(const TerScorer&); - ~TerScorer() {}; + ~TerScorer() {} TerScorer& operator=(const TerScorer&); // data extracted from reference files diff --git a/mert/Util.cpp b/mert/Util.cpp index 244e8c791..b9077a2f6 100644 --- a/mert/Util.cpp +++ b/mert/Util.cpp @@ -54,7 +54,7 @@ size_t getNextPound(std::string &theString, std::string &substring, const std::s } } return pos; -}; +} void split(const std::string &s, char delim, std::vector<std::string> &elems) { std::stringstream ss(s); @@ -143,12 +143,12 @@ int swapbytes(char *p, int sz, int n) } return 0; -}; +} void ResetUserTime() { g_timer.start(); -}; +} void PrintUserTime(const std::string &message) { diff --git a/mert/Util.h b/mert/Util.h index 9d1771551..765cd2cb4 100644 --- a/mert/Util.h +++ b/mert/Util.h @@ -58,7 +58,7 @@ inline T Scan(const std::string &input) T ret; stream >> ret; return ret; -}; +} class inputfilestream : public std::istream { |