mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Move 'using namespace std' out from .h.
Add "std" to size_t, too.
This commit is contained in:
parent
01eb60f350
commit
beb2256dba
@ -27,10 +27,10 @@ public:
|
||||
virtual bool finished() = 0;
|
||||
virtual void next() = 0;
|
||||
|
||||
virtual size_t cur_size() = 0;
|
||||
virtual size_t num_dense() const = 0;
|
||||
virtual const FeatureDataItem& featuresAt(size_t i) = 0;
|
||||
virtual const ScoreDataItem& scoresAt(size_t i) = 0;
|
||||
virtual std::size_t cur_size() = 0;
|
||||
virtual std::size_t num_dense() const = 0;
|
||||
virtual const FeatureDataItem& featuresAt(std::size_t i) = 0;
|
||||
virtual const ScoreDataItem& scoresAt(std::size_t i) = 0;
|
||||
};
|
||||
|
||||
// Instantiation that streams from disk
|
||||
@ -38,23 +38,22 @@ public:
|
||||
class StreamingHypPackEnumerator : public HypPackEnumerator {
|
||||
public:
|
||||
StreamingHypPackEnumerator(std::vector<std::string> const& featureFiles,
|
||||
std::vector<std::string> const& scoreFiles
|
||||
);
|
||||
std::vector<std::string> const& scoreFiles);
|
||||
|
||||
virtual std::size_t num_dense() const;
|
||||
|
||||
virtual size_t num_dense() const;
|
||||
|
||||
virtual void reset();
|
||||
virtual bool finished();
|
||||
virtual void next();
|
||||
|
||||
virtual size_t cur_size();
|
||||
virtual const FeatureDataItem& featuresAt(size_t i);
|
||||
virtual const ScoreDataItem& scoresAt(size_t i);
|
||||
|
||||
virtual std::size_t cur_size();
|
||||
virtual const FeatureDataItem& featuresAt(std::size_t i);
|
||||
virtual const ScoreDataItem& scoresAt(std::size_t i);
|
||||
|
||||
private:
|
||||
void prime();
|
||||
size_t m_num_lists;
|
||||
size_t m_sentenceId;
|
||||
std::size_t m_num_lists;
|
||||
std::size_t m_sentenceId;
|
||||
std::vector<std::string> m_featureFiles;
|
||||
std::vector<std::string> m_scoreFiles;
|
||||
|
||||
@ -62,7 +61,7 @@ private:
|
||||
int m_iNumDense;
|
||||
std::vector<FeatureDataIterator> m_featureDataIters;
|
||||
std::vector<ScoreDataIterator> m_scoreDataIters;
|
||||
std::vector<std::pair<size_t,size_t> > m_current_indexes;
|
||||
std::vector<std::pair<std::size_t,std::size_t> > m_current_indexes;
|
||||
};
|
||||
|
||||
// Instantiation that reads into memory
|
||||
@ -74,21 +73,21 @@ public:
|
||||
std::vector<std::string> const& scoreFiles,
|
||||
bool no_shuffle);
|
||||
|
||||
virtual size_t num_dense() const;
|
||||
|
||||
virtual std::size_t num_dense() const;
|
||||
|
||||
virtual void reset();
|
||||
virtual bool finished();
|
||||
virtual void next();
|
||||
|
||||
virtual size_t cur_size();
|
||||
virtual const FeatureDataItem& featuresAt(size_t i);
|
||||
virtual const ScoreDataItem& scoresAt(size_t i);
|
||||
virtual std::size_t cur_size();
|
||||
virtual const FeatureDataItem& featuresAt(std::size_t i);
|
||||
virtual const ScoreDataItem& scoresAt(std::size_t i);
|
||||
|
||||
private:
|
||||
bool m_no_shuffle;
|
||||
size_t m_cur_index;
|
||||
size_t m_num_dense;
|
||||
std::vector<size_t> m_indexes;
|
||||
std::size_t m_cur_index;
|
||||
std::size_t m_num_dense;
|
||||
std::vector<std::size_t> m_indexes;
|
||||
std::vector<std::vector<FeatureDataItem> > m_features;
|
||||
std::vector<std::vector<ScoreDataItem> > m_scores;
|
||||
};
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include "MiraFeatureVector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
MiraFeatureVector::MiraFeatureVector(const FeatureDataItem& vec)
|
||||
: m_dense(vec.dense)
|
||||
{
|
||||
@ -97,7 +99,7 @@ MiraFeatureVector operator-(const MiraFeatureVector& a, const MiraFeatureVector&
|
||||
vector<ValType> sparseVals;
|
||||
vector<size_t> sparseFeats;
|
||||
while(i < a.m_sparseFeats.size() && j < b.m_sparseFeats.size()) {
|
||||
|
||||
|
||||
if(a.m_sparseFeats[i] < b.m_sparseFeats[j]) {
|
||||
sparseFeats.push_back(a.m_sparseFeats[i]);
|
||||
sparseVals.push_back(a.m_sparseVals[i]);
|
||||
@ -136,7 +138,7 @@ MiraFeatureVector operator-(const MiraFeatureVector& a, const MiraFeatureVector&
|
||||
// Create and return vector
|
||||
return MiraFeatureVector(dense,sparseFeats,sparseVals);
|
||||
}
|
||||
|
||||
|
||||
// --Emacs trickery--
|
||||
// Local Variables:
|
||||
// mode:c++
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
#include "FeatureDataIterator.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef FeatureStatsType ValType;
|
||||
|
||||
class MiraFeatureVector {
|
||||
@ -25,20 +23,20 @@ public:
|
||||
MiraFeatureVector(const FeatureDataItem& vec);
|
||||
MiraFeatureVector(const MiraFeatureVector& other);
|
||||
MiraFeatureVector(const std::vector<ValType>& dense,
|
||||
const std::vector<size_t>& sparseFeats,
|
||||
const std::vector<std::size_t>& sparseFeats,
|
||||
const std::vector<ValType>& sparseVals);
|
||||
|
||||
ValType val(size_t index) const;
|
||||
size_t feat(size_t index) const;
|
||||
size_t size() const;
|
||||
|
||||
ValType val(std::size_t index) const;
|
||||
std::size_t feat(std::size_t index) const;
|
||||
std::size_t size() const;
|
||||
ValType sqrNorm() const;
|
||||
|
||||
|
||||
friend MiraFeatureVector operator-(const MiraFeatureVector& a,
|
||||
const MiraFeatureVector& b);
|
||||
|
||||
|
||||
private:
|
||||
std::vector<ValType> m_dense;
|
||||
std::vector<size_t> m_sparseFeats;
|
||||
std::vector<std::size_t> m_sparseFeats;
|
||||
std::vector<ValType> m_sparseVals;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "MiraWeightVector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Constructor, initializes to the zero vector
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* A self-averaging weight-vector. Good for
|
||||
* perceptron learning as well.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MERT_MIRA_WEIGHT_VECTOR_H
|
||||
@ -14,8 +14,6 @@
|
||||
|
||||
#include "MiraFeatureVector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AvgWeightVector;
|
||||
|
||||
class MiraWeightVector {
|
||||
@ -29,7 +27,7 @@ public:
|
||||
* Constructor with provided initial vector
|
||||
* \param init Initial feature values
|
||||
*/
|
||||
MiraWeightVector(const vector<ValType>& init);
|
||||
MiraWeightVector(const std::vector<ValType>& init);
|
||||
|
||||
/**
|
||||
* Update a the model
|
||||
@ -60,12 +58,12 @@ public:
|
||||
AvgWeightVector avg();
|
||||
|
||||
friend class AvgWeightVector;
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Updates a weight and lazily updates its total
|
||||
*/
|
||||
void update(size_t index, ValType delta);
|
||||
void update(std::size_t index, ValType delta);
|
||||
|
||||
/**
|
||||
* Make sure everyone's total is up-to-date
|
||||
@ -75,12 +73,12 @@ private:
|
||||
/**
|
||||
* Helper to handle out-of-range weights
|
||||
*/
|
||||
ValType weight(size_t index) const;
|
||||
|
||||
vector<ValType> m_weights;
|
||||
vector<ValType> m_totals;
|
||||
vector<size_t> m_lastUpdated;
|
||||
size_t m_numUpdates;
|
||||
ValType weight(std::size_t index) const;
|
||||
|
||||
std::vector<ValType> m_weights;
|
||||
std::vector<ValType> m_totals;
|
||||
std::vector<std::size_t> m_lastUpdated;
|
||||
std::size_t m_numUpdates;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -90,8 +88,8 @@ class AvgWeightVector {
|
||||
public:
|
||||
AvgWeightVector(const MiraWeightVector& wv);
|
||||
ValType score(const MiraFeatureVector& fv) const;
|
||||
ValType weight(size_t index) const;
|
||||
size_t size() const;
|
||||
ValType weight(std::size_t index) const;
|
||||
std::size_t size() const;
|
||||
private:
|
||||
const MiraWeightVector& m_wv;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user