namespace all classes in mert directory

This commit is contained in:
Hieu Hoang 2012-06-30 20:23:45 +01:00
parent 1cf1c2e515
commit e3dd3a8d2c
72 changed files with 431 additions and 16 deletions

View File

@ -26,6 +26,10 @@ const char REFLEN_CLOSEST[] = "closest";
} // namespace
namespace MosesTuning
{
BleuScorer::BleuScorer(const string& config)
: StatisticsBasedScorer("BLEU", config),
m_ref_length_type(CLOSEST) {
@ -273,3 +277,6 @@ float unsmoothedBleu(const std::vector<float>& stats) {
}
return exp(logbleu);
}
}

View File

@ -10,10 +10,13 @@
#include "StatisticsBasedScorer.h"
#include "ScopedVector.h"
namespace MosesTuning
{
const int kBleuNgramOrder = 4;
class NgramCounts;
class Reference;
class Reference;
/**
* Bleu scoring
@ -80,4 +83,6 @@ float sentenceLevelBackgroundBleu(const std::vector<float>& sent, const std::vec
*/
float unsmoothedBleu(const std::vector<float>& stats);
}
#endif // MERT_BLEU_SCORER_H_

View File

@ -14,6 +14,10 @@ inline int CalcDistance(int word1, int word2) {
} // namespace
namespace MosesTuning
{
CderScorer::CderScorer(const string& config, bool allowed_long_jumps)
: StatisticsBasedScorer(allowed_long_jumps ? "CDER" : "WER", config),
m_allowed_long_jumps(allowed_long_jumps) {}
@ -124,3 +128,5 @@ void CderScorer::computeCD(const sent_t& cand, const sent_t& ref,
delete row;
}
}

View File

@ -6,6 +6,10 @@
#include "Types.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
/**
* CderScorer class can compute both CDER and WER metric.
*/
@ -38,4 +42,6 @@ class CderScorer: public StatisticsBasedScorer {
CderScorer& operator=(const CderScorer&);
};
}
#endif // MERT_CDER_SCORER_H_

View File

@ -19,6 +19,10 @@
using namespace std;
namespace MosesTuning
{
Data::Data()
: m_scorer(NULL),
m_num_scores(0),
@ -269,3 +273,6 @@ void Data::createShards(size_t shard_count, float shard_size, const string& scor
//cerr << endl;
}
}
}

View File

@ -16,6 +16,9 @@
#include "FeatureData.h"
#include "ScoreData.h"
namespace MosesTuning
{
class Scorer;
typedef boost::shared_ptr<ScoreData> ScoreDataHandle;
@ -97,4 +100,6 @@ public:
const std::string& sentence_index);
};
}
#endif // MERT_DATA_H_

View File

@ -13,6 +13,9 @@
#define BUFFER_SIZE (32768)
namespace MosesTuning
{
class _fdstream
{
protected:
@ -164,4 +167,6 @@ private:
#error "Not supported"
#endif
}
#endif // _FDSTREAM_

View File

@ -14,6 +14,10 @@
using namespace std;
namespace MosesTuning
{
FeatureArray::FeatureArray()
: m_index(""), m_num_features(0), m_sparse_flag(false) {}
@ -165,3 +169,6 @@ bool FeatureArray::check_consistency() const
}
return true;
}
}

View File

@ -13,6 +13,10 @@
#include <iosfwd>
#include "FeatureStats.h"
namespace MosesTuning
{
const char FEATURES_TXT_BEGIN[] = "FEATURES_TXT_BEGIN_0";
const char FEATURES_TXT_END[] = "FEATURES_TXT_END_0";
const char FEATURES_BIN_BEGIN[] = "FEATURES_BIN_BEGIN_0";
@ -79,4 +83,6 @@ public:
bool check_consistency() const;
};
}
#endif // MERT_FEATURE_ARRAY_H_

View File

@ -14,6 +14,10 @@
using namespace std;
namespace MosesTuning
{
static const float MIN_FLOAT = -1.0 * numeric_limits<float>::max();
static const float MAX_FLOAT = numeric_limits<float>::max();
@ -174,3 +178,6 @@ string FeatureData::ToString() const {
return res;
}
}

View File

@ -14,6 +14,10 @@
#include <stdexcept>
#include "FeatureArray.h"
namespace MosesTuning
{
class FeatureData
{
private:
@ -130,4 +134,6 @@ public:
std::string ToString() const;
};
}
#endif // MERT_FEATURE_DATA_H_

View File

@ -29,6 +29,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
using namespace std;
using namespace util;
namespace MosesTuning
{
int ParseInt(const StringPiece& str ) {
char* errIndex;
//could wrap?
@ -130,3 +134,6 @@ bool FeatureDataIterator::equal(const FeatureDataIterator& rhs) const {
const vector<FeatureDataItem>& FeatureDataIterator::dereference() const {
return m_next;
}
}

View File

@ -37,6 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "FeatureStats.h"
namespace MosesTuning
{
class FileFormatException : public util::Exception
{
@ -91,4 +94,6 @@ class FeatureDataIterator :
std::vector<FeatureDataItem> m_next;
};
}
#endif // MERT_FEATURE_DATA_ITERATOR_H_

View File

@ -20,6 +20,10 @@ namespace {
const int kAvailableSize = 8;
} // namespace
namespace MosesTuning
{
SparseVector::name2id_t SparseVector::m_name_to_id;
SparseVector::id2name_t SparseVector::m_id_to_name;
@ -263,7 +267,6 @@ ostream& operator<<(ostream& o, const FeatureStats& e)
return o;
}
//ADEED_BY_TS
bool operator==(const FeatureStats& f1, const FeatureStats& f2) {
size_t size = f1.size();
@ -277,4 +280,5 @@ bool operator==(const FeatureStats& f1, const FeatureStats& f2) {
return true;
}
//END_ADDED
}

View File

@ -16,6 +16,10 @@
#include <vector>
#include "Types.h"
namespace MosesTuning
{
// Minimal sparse vector
class SparseVector {
public:
@ -120,8 +124,8 @@ public:
friend std::ostream& operator<<(std::ostream& o, const FeatureStats& e);
};
//ADEED_BY_TS
bool operator==(const FeatureStats& f1, const FeatureStats& f2);
//END_ADDED
}
#endif // MERT_FEATURE_STATS_H_

View File

@ -6,6 +6,10 @@
using namespace std;
namespace MosesTuning
{
StreamingHypPackEnumerator::StreamingHypPackEnumerator
(
vector<std::string> const& featureFiles,
@ -195,3 +199,5 @@ size_t RandomAccessHypPackEnumerator::cur_id() {
// mode:c++
// c-basic-offset:2
// End:
}

View File

@ -18,6 +18,10 @@
#include "ScoreDataIterator.h"
#include "MiraFeatureVector.h"
namespace MosesTuning
{
// Start with these abstract classes
class HypPackEnumerator {
@ -97,6 +101,8 @@ private:
std::vector<std::vector<ScoreDataItem> > m_scores;
};
}
#endif // MERT_HYP_PACK_COLLECTION_H
// --Emacs trickery--

View File

@ -4,6 +4,10 @@
using namespace std;
namespace MosesTuning
{
// TODO: This is too long. Consider creating a function for
// initialization such as Init().
InterpolatedScorer::InterpolatedScorer(const string& name, const string& config)
@ -195,3 +199,6 @@ void InterpolatedScorer::setFilter(const string& filterCommand)
m_scorers[i]->setFilter(csplit[i]);
}
}
}

View File

@ -8,6 +8,10 @@
#include "Scorer.h"
#include "ScopedVector.h"
namespace MosesTuning
{
/**
* Class that includes other scorers eg.
* Interpolated HAMMING and BLEU scorer **/
@ -52,4 +56,6 @@ protected:
std::vector<float> m_scorer_weights;
};
}
#endif // MERT_INTERPOLATED_SCORER_H_

View File

@ -14,6 +14,10 @@
using namespace std;
using namespace TERCpp;
namespace MosesTuning
{
MergeScorer::MergeScorer(const string& config)
: StatisticsBasedScorer("MERGE", config) {}
@ -121,3 +125,6 @@ float MergeScorer::calculateScore(const std::vector< int >& comps) const
}
return result;
}
}

View File

@ -6,6 +6,10 @@
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
class PerScorer;
class ScoreStats;
@ -33,4 +37,6 @@ protected:
MergeScorer& operator=(const MergeScorer&);
};
}
#endif // MERT_MERGE_SCORER_H_

View File

@ -5,6 +5,10 @@
using namespace std;
namespace MosesTuning
{
MiraFeatureVector::MiraFeatureVector(const FeatureDataItem& vec)
: m_dense(vec.dense)
{
@ -156,3 +160,6 @@ ostream& operator<<(ostream& o, const MiraFeatureVector& e)
// mode:c++
// c-basic-offset:2
// End:
}

View File

@ -17,6 +17,10 @@
#include "FeatureDataIterator.h"
namespace MosesTuning
{
typedef FeatureStatsType ValType;
class MiraFeatureVector {
@ -50,3 +54,5 @@ private:
// mode:c++
// c-basic-offset:2
// End:
}

View File

@ -4,6 +4,10 @@
using namespace std;
namespace MosesTuning
{
/**
* Constructor, initializes to the zero vector
*/
@ -156,3 +160,5 @@ size_t AvgWeightVector::size() const {
// mode:c++
// c-basic-offset:2
// End:
}

View File

@ -15,6 +15,10 @@
#include "MiraFeatureVector.h"
namespace MosesTuning
{
class AvgWeightVector;
class MiraWeightVector {
@ -105,3 +109,5 @@ private:
// mode:c++
// c-basic-offset:2
// End:
}

View File

@ -5,6 +5,9 @@
#include <map>
#include <string>
namespace MosesTuning
{
/** A simple STL-std::map based n-gram counts. Basically, we provide
* typical accessors and mutaors, but we intentionally does not allow
* erasing elements.
@ -95,4 +98,6 @@ class NgramCounts {
std::map<Key, Value, NgramComparator> m_counts;
};
}
#endif // MERT_NGRAM_H_

View File

@ -33,6 +33,10 @@ inline float intersect(float m1, float b1, float m2, float b2)
} // namespace
namespace MosesTuning
{
Optimizer::Optimizer(unsigned Pd, const vector<unsigned>& i2O, const vector<bool>& pos, const vector<parameter_t>& start, unsigned int nrandom)
: m_scorer(NULL), m_feature_data(), m_num_random_directions(nrandom), m_positive(pos)
{
@ -472,3 +476,5 @@ statscore_t RandomOptimizer::TrueRun(Point& P) const
P.SetScore(score);
return score;
}
}

View File

@ -10,6 +10,10 @@
static const float kMaxFloat = std::numeric_limits<float>::max();
namespace MosesTuning
{
class Point;
/**
@ -109,4 +113,6 @@ public:
virtual statscore_t TrueRun(Point&) const;
};
}
#endif // OPTIMIZER_H

View File

@ -3,6 +3,10 @@
using namespace std;
namespace MosesTuning
{
vector<string> OptimizerFactory::m_type_names;
void OptimizerFactory::SetTypeNames()
@ -65,3 +69,5 @@ Optimizer* OptimizerFactory::BuildOptimizer(unsigned dim,
return NULL;
}
}
}

View File

@ -4,6 +4,10 @@
#include <vector>
#include "Types.h"
namespace MosesTuning
{
class Optimizer;
class OptimizerFactory
@ -39,4 +43,7 @@ class OptimizerFactory
static std::vector<std::string> m_type_names;
};
}
#endif // MERT_OPTIMIZER_FACTORY_H_

View File

@ -8,6 +8,10 @@
using namespace std;
namespace MosesTuning
{
PerScorer::PerScorer(const string& config)
: StatisticsBasedScorer("PER",config) {}
@ -86,3 +90,6 @@ float PerScorer::calculateScore(const vector<int>& comps) const
return num/denom;
}
}
}

View File

@ -7,6 +7,10 @@
#include "Types.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
class ScoreStats;
/**
@ -36,4 +40,6 @@ private:
std::vector<std::multiset<int> > m_ref_tokens;
};
}
#endif // MERT_PER_SCORER_H_

View File

@ -14,6 +14,10 @@
using namespace std;
namespace MosesTuning
{
Permutation::Permutation(const string &alignment, const int sourceLength, const int targetLength )
{
if (sourceLength > 0) {
@ -318,3 +322,5 @@ string Permutation::convertMosesToStandard(string const & alignment)
return out;
}
}

View File

@ -17,6 +17,9 @@
#include "Util.h"
namespace MosesTuning
{
class Permutation
{
@ -63,4 +66,6 @@ private:
};
}
#endif

View File

@ -3,6 +3,10 @@
using namespace std;
namespace MosesTuning
{
const int PermutationScorer::SCORE_PRECISION = 5;
PermutationScorer::PermutationScorer(const string &distanceMetric, const string &config)
@ -214,3 +218,5 @@ statscore_t PermutationScorer::calculateScore(const vector<int>& comps) const
return comps[0];
}
}

View File

@ -17,6 +17,9 @@
#include "Permutation.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
/**
* Permutation
**/
@ -60,6 +63,8 @@ private:
};
//TODO need to read in floats for scores - necessary for selecting mean reference strategy and for BLEU?
}
#endif //__PERMUTATIONSCORER_H

View File

@ -8,6 +8,9 @@
using namespace std;
namespace MosesTuning
{
vector<unsigned> Point::m_opt_indices;
unsigned Point::m_dim = 0;
@ -156,3 +159,6 @@ void Point::GetAllWeights(vector<parameter_t>& w) const
}
}
}
}

View File

@ -6,6 +6,10 @@
#include <vector>
#include "Types.h"
namespace MosesTuning
{
class FeatureStats;
class Optimizer;
@ -100,4 +104,6 @@ public:
void SetScore(statscore_t score) { m_score = score; }
};
}
#endif // MERT_POINT_H

View File

@ -16,6 +16,10 @@ using namespace std;
#define CHILD_STDERR_READ pipefds_error[0]
#define CHILD_STDERR_WRITE pipefds_error[1]
namespace MosesTuning
{
// Child exec error signal
void exec_failed (int sig)
{
@ -135,3 +139,6 @@ PreProcessFilter::~PreProcessFilter()
delete m_toFilter;
delete m_fromFilter;
}
}

View File

@ -3,6 +3,10 @@
#include <string>
namespace MosesTuning
{
class ofdstream;
class ifdstream;
@ -22,4 +26,6 @@ private:
ifdstream* m_fromFilter;
};
}
#endif // MERT_PREPROCESSFILTER_H_

View File

@ -7,6 +7,10 @@
#include "Ngram.h"
namespace MosesTuning
{
/**
* Reference class represents reference translations for an output
* translation used in calculating BLEU score.
@ -79,4 +83,7 @@ inline int Reference::CalcShortest() const {
return *std::min_element(m_length.begin(), m_length.end());
}
}
#endif // MERT_REFERENCE_H_

View File

@ -3,6 +3,9 @@
#include <vector>
namespace MosesTuning
{
template <class T>
class ScopedVector {
public:
@ -51,4 +54,6 @@ class ScopedVector {
void operator=(const ScopedVector<T>&);
};
}
#endif // MERT_SCOPED_VECTOR_H_

View File

@ -12,6 +12,10 @@
using namespace std;
namespace MosesTuning
{
ScoreArray::ScoreArray()
: m_num_scores(0), m_index("") {}
@ -160,3 +164,6 @@ bool ScoreArray::check_consistency() const
}
return true;
}
}

View File

@ -15,6 +15,9 @@
#include "ScoreStats.h"
namespace MosesTuning
{
const char SCORES_TXT_BEGIN[] = "SCORES_TXT_BEGIN_0";
const char SCORES_TXT_END[] = "SCORES_TXT_END_0";
const char SCORES_BIN_BEGIN[] = "SCORES_BIN_BEGIN_0";
@ -83,4 +86,6 @@ public:
bool check_consistency() const;
};
}
#endif // MERT_SCORE_ARRAY_H_

View File

@ -16,6 +16,10 @@
using namespace std;
namespace MosesTuning
{
ScoreData::ScoreData(Scorer* scorer) :
m_scorer(scorer)
{
@ -133,3 +137,6 @@ void ScoreData::setIndex()
j++;
}
}
}

View File

@ -16,6 +16,10 @@
#include "ScoreArray.h"
#include "ScoreStats.h"
namespace MosesTuning
{
class Scorer;
class ScoreData
@ -105,4 +109,6 @@ public:
}
};
}
#endif // MERT_SCORE_DATA_H_

View File

@ -26,6 +26,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
using namespace std;
using namespace util;
namespace MosesTuning
{
ScoreDataIterator::ScoreDataIterator() {}
ScoreDataIterator::ScoreDataIterator(const string& filename) {
@ -87,3 +91,5 @@ const vector<ScoreDataItem>& ScoreDataIterator::dereference() const {
return m_next;
}
}

View File

@ -34,6 +34,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "FeatureDataIterator.h"
namespace MosesTuning
{
typedef std::vector<float> ScoreDataItem;
class ScoreDataIterator :
@ -62,4 +66,7 @@ class ScoreDataIterator :
std::vector<ScoreDataItem> m_next;
};
}
#endif // MERT_SCORE_DATA_ITERATOR_H_

View File

@ -17,6 +17,10 @@ namespace {
const int kAvailableSize = 8;
} // namespace
namespace MosesTuning
{
ScoreStats::ScoreStats()
: m_available_size(kAvailableSize), m_entries(0),
m_array(new ScoreStatsType[m_available_size]) {}
@ -136,7 +140,6 @@ ostream& operator<<(ostream& o, const ScoreStats& e)
return o;
}
//ADDED_BY_TS
bool operator==(const ScoreStats& s1, const ScoreStats& s2) {
size_t size = s1.size();
@ -150,4 +153,5 @@ bool operator==(const ScoreStats& s1, const ScoreStats& s2) {
return true;
}
//END_ADDED
}

View File

@ -16,6 +16,10 @@
#include "Types.h"
namespace MosesTuning
{
class ScoreStats
{
private:
@ -90,8 +94,8 @@ public:
friend std::ostream& operator<<(std::ostream& o, const ScoreStats& e);
};
//ADDED_BY_TS
bool operator==(const ScoreStats& s1, const ScoreStats& s2);
//END_ADDED
}
#endif // MERT_SCORE_STATS_H_

View File

@ -8,6 +8,10 @@
using namespace std;
namespace MosesTuning
{
Scorer::Scorer(const string& name, const string& config)
: m_name(name),
m_vocab(mert::VocabularyFactory::GetVocabulary()),
@ -137,3 +141,4 @@ float Scorer::score(const candidates_t& candidates) const {
return scores[0];
}
}

View File

@ -10,15 +10,18 @@
#include "Types.h"
#include "ScoreData.h"
class PreProcessFilter;
class ScoreStats;
namespace mert {
class Vocabulary;
} // namespace mert
namespace MosesTuning
{
class PreProcessFilter;
class ScoreStats;
enum ScorerRegularisationStrategy {REG_NONE, REG_AVERAGE, REG_MINIMUM};
/**
@ -193,5 +196,6 @@ namespace {
} // namespace
}
#endif // MERT_SCORER_H_

View File

@ -13,6 +13,10 @@
using namespace std;
namespace MosesTuning
{
vector<string> ScorerFactory::getTypes() {
vector<string> types;
types.push_back(string("BLEU"));
@ -53,3 +57,6 @@ Scorer* ScorerFactory::getScorer(const string& type, const string& config) {
}
}
}
}

View File

@ -4,6 +4,10 @@
#include <vector>
#include <string>
namespace MosesTuning
{
class Scorer;
class ScorerFactory
@ -18,4 +22,6 @@ private:
~ScorerFactory() {}
};
}
#endif // MERT_SCORER_FACTORY_H_

View File

@ -8,10 +8,14 @@ using namespace std;
namespace {
SemposOverlapping* g_overlapping = NULL;
MosesTuning::SemposOverlapping* g_overlapping = NULL;
} // namespace
namespace MosesTuning
{
SemposOverlapping* SemposOverlappingFactory::GetOverlapping(const string& str, const SemposScorer* sempos) {
if (str == "cap-micro") {
return new CapMicroOverlapping(sempos);
@ -107,3 +111,5 @@ float CapMacroOverlapping::calculateScore(const vector<int>& stats) const
if (n == 0) return 1;
return sum / n;
}
}

View File

@ -7,6 +7,10 @@
#include <utility>
#include <vector>
namespace MosesTuning
{
class SemposScorer;
// TODO: need comments about this number.
@ -87,4 +91,6 @@ public:
const SemposScorer* semposScorer;
};
}
#endif // MERT_SEMPOSOVERLAPPING_H_

View File

@ -10,6 +10,10 @@
using namespace std;
namespace MosesTuning
{
SemposScorer::SemposScorer(const string& config)
: StatisticsBasedScorer("SEMPOS", config),
m_ovr(SemposOverlappingFactory::GetOverlapping(getConfig("overlapping", "cap-micro"),this)),
@ -178,3 +182,6 @@ void SemposScorer::loadWeights(const string& weightsfile)
}
}
}

View File

@ -17,6 +17,10 @@
#include "SemposOverlapping.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
/**
* This class represents sempos based metrics.
*/
@ -62,4 +66,6 @@ private:
SemposScorer& operator=(const SemposScorer&);
};
}
#endif // MERT_SEMPOSSCORER_H_

View File

@ -11,6 +11,9 @@
using namespace std;
namespace MosesTuning
{
/** The sentence level scores have already been calculated, just need to average them
and include the differences. Allows scores which are floats **/
@ -100,3 +103,6 @@ void SentenceLevelScorer::score(const candidates_t& candidates, const diffs_t&
}
}
}
}

View File

@ -15,6 +15,10 @@
#include <vector>
#include <boost/spirit/home/support/detail/lexer/runtime_error.hpp>
namespace MosesTuning
{
/**
* Abstract base class for scorers that work by using sentence level
* statistics eg. permutation distance metrics **/
@ -79,5 +83,6 @@ protected:
};
}
#endif

View File

@ -3,6 +3,10 @@
#include <cstdlib>
namespace MosesTuning
{
// thread *un*safe singleton.
// TODO: replace this with thread-safe singleton.
template <typename T>
@ -30,4 +34,6 @@ class Singleton {
template <typename T>
T* Singleton<T>::m_instance = NULL;
}
#endif // MERT_SINGLETON_H_

View File

@ -11,6 +11,10 @@
using namespace std;
namespace MosesTuning
{
StatisticsBasedScorer::StatisticsBasedScorer(const string& name, const string& config)
: Scorer(name,config) {
//configure regularisation
@ -117,3 +121,6 @@ void StatisticsBasedScorer::score(const candidates_t& candidates, const diffs_t
}
}
}
}

View File

@ -10,6 +10,11 @@
#define mert_lib_StatisticsBasedScorer_h
#include "Scorer.h"
namespace MosesTuning
{
/**
* Abstract base class for Scorers that work by adding statistics across all
* outout sentences, then apply some formula, e.g., BLEU, PER.
@ -40,6 +45,6 @@ protected:
std::size_t m_regularization_window;
};
} // namespace
#endif

View File

@ -12,6 +12,10 @@
using namespace std;
using namespace TERCpp;
namespace MosesTuning
{
TerScorer::TerScorer(const string& config)
: StatisticsBasedScorer("TER",config), kLENGTH(2) {}
@ -108,3 +112,5 @@ float TerScorer::calculateScore(const vector<int>& comps) const
return (1.0+(num / denom));
}
}
}

View File

@ -8,6 +8,10 @@
#include "Types.h"
#include "StatisticsBasedScorer.h"
namespace MosesTuning
{
class ScoreStats;
/**
@ -47,4 +51,6 @@ private:
TerScorer& operator=(const TerScorer&);
};
}
#endif // MERT_TER_SCORER_H_

View File

@ -22,6 +22,10 @@ uint64_t GetTimeOfDayMicroSeconds() {
} // namespace
namespace MosesTuning
{
void Timer::GetCPUTimeMicroSeconds(Timer::CPUTime* cpu_time) const {
#if !defined(_WIN32) && !defined(_WIN64)
struct rusage usage;
@ -102,3 +106,5 @@ std::string Timer::ToString() const {
return res;
}
}

View File

@ -5,6 +5,10 @@
#include <string>
#include <stdint.h>
namespace MosesTuning
{
class Timer
{
private:
@ -102,4 +106,7 @@ inline std::ostream& operator<<(std::ostream& os, const Timer& t) {
return os;
}
}
#endif // MERT_TIMER_H_

View File

@ -6,6 +6,9 @@
#include <string>
#include <utility>
namespace MosesTuning
{
class FeatureStats;
class FeatureArray;
class FeatureData;
@ -42,4 +45,6 @@ typedef std::map<std::string, std::size_t> name2idx;
typedef enum { HAMMING_DISTANCE=0, KENDALL_DISTANCE } distanceMetric_t;
typedef enum { REFERENCE_CHOICE_AVERAGE=0, REFERENCE_CHOICE_CLOSEST } distanceMetricReferenceChoice_t;
}
#endif // MERT_TYPE_H_

View File

@ -13,7 +13,7 @@ using namespace std;
namespace {
Timer g_timer;
MosesTuning::Timer g_timer;
int g_verbose = 0;
bool FindDelimiter(const std::string &str, const std::string &delim, size_t *pos)
@ -24,6 +24,9 @@ bool FindDelimiter(const std::string &str, const std::string &delim, size_t *pos
} // namespace
namespace MosesTuning
{
int verboselevel()
{
return g_verbose;
@ -86,3 +89,5 @@ double GetUserTime()
{
return g_timer.get_elapsed_cpu_time();
}
}

View File

@ -22,6 +22,9 @@
#include "Types.h"
namespace MosesTuning
{
#ifdef TRACE_ENABLE
#define TRACE_ERR(str) { std::cerr << str; }
#else
@ -130,4 +133,6 @@ void ResetUserTime();
void PrintUserTime(const std::string &message);
double GetUserTime();
}
#endif // MERT_UTIL_H_

View File

@ -30,7 +30,7 @@ bool Vocabulary::Lookup(const std::string&str , int* v) const {
Vocabulary* VocabularyFactory::GetVocabulary() {
if (g_vocab == NULL) {
return Singleton<Vocabulary>::GetInstance();
return MosesTuning::Singleton<Vocabulary>::GetInstance();
} else {
return g_vocab;
}

View File

@ -28,6 +28,7 @@
#include "../moses/src/ThreadPool.h"
using namespace std;
using namespace MosesTuning;
namespace {