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
path: root/mert
diff options
context:
space:
mode:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2012-05-05 20:31:04 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2012-05-05 20:31:04 +0400
commitb6f55f6bec8971d1aa42f6d796787878381d2e4c (patch)
tree2b9ddaaf3cb0ec26ca58464d7b96def4463cf1ea /mert
parent3f2cbcc84629c5f53a39e9bb7fc14860e218208f (diff)
Fix using namespace "std" before including headers in *.h.
Diffstat (limited to 'mert')
-rw-r--r--mert/FeatureData.cpp2
-rw-r--r--mert/FeatureData.h38
-rw-r--r--mert/ScoreArray.cpp2
-rw-r--r--mert/ScoreArray.h22
4 files changed, 32 insertions, 32 deletions
diff --git a/mert/FeatureData.cpp b/mert/FeatureData.cpp
index 957d36ad4..acc144d1a 100644
--- a/mert/FeatureData.cpp
+++ b/mert/FeatureData.cpp
@@ -12,6 +12,8 @@
#include "FileStream.h"
#include "Util.h"
+using namespace std;
+
static const float MIN_FLOAT = -1.0 * numeric_limits<float>::max();
static const float MAX_FLOAT = numeric_limits<float>::max();
diff --git a/mert/FeatureData.h b/mert/FeatureData.h
index 5186da1b8..aef1ef250 100644
--- a/mert/FeatureData.h
+++ b/mert/FeatureData.h
@@ -9,8 +9,6 @@
#ifndef MERT_FEATURE_DATA_H_
#define MERT_FEATURE_DATA_H_
-using namespace std;
-
#include <vector>
#include <iostream>
#include <stdexcept>
@@ -19,11 +17,11 @@ using namespace std;
class FeatureData
{
private:
- size_t m_num_features;
+ std::size_t m_num_features;
std::string m_features;
bool m_sparse_flag;
- map<std::string, size_t> m_feature_name_to_index; // map from name to index of features
- map<size_t, std::string> m_index_to_feature_name; // map from index to name of features
+ std::map<std::string, std::size_t> m_feature_name_to_index; // map from name to index of features
+ std::map<std::size_t, std::string> m_index_to_feature_name; // map from index to name of features
featdata_t m_array;
idx2name m_index_to_array_name; // map from index to name of array
name2idx m_array_name_to_index; // map from name to index of array
@@ -40,8 +38,8 @@ public:
return m_array.at(getIndex(idx));
}
- FeatureArray& get(size_t idx) { return m_array.at(idx); }
- const FeatureArray& get(size_t idx) const { return m_array.at(idx); }
+ FeatureArray& get(std::size_t idx) { return m_array.at(idx); }
+ const FeatureArray& get(std::size_t idx) const { return m_array.at(idx); }
inline bool exists(const std::string& sent_idx) const {
return exists(getIndex(sent_idx));
@@ -51,21 +49,21 @@ public:
return (sent_idx > -1 && sent_idx < static_cast<int>(m_array.size())) ? true : false;
}
- inline FeatureStats& get(size_t i, size_t j) {
+ inline FeatureStats& get(std::size_t i, std::size_t j) {
return m_array.at(i).get(j);
}
- inline const FeatureStats& get(size_t i, size_t j) const {
+ inline const FeatureStats& get(std::size_t i, std::size_t j) const {
return m_array.at(i).get(j);
}
void add(FeatureArray& e);
void add(FeatureStats& e, const std::string& sent_idx);
- size_t size() const { return m_array.size(); }
+ std::size_t size() const { return m_array.size(); }
- size_t NumberOfFeatures() const { return m_num_features; }
- void NumberOfFeatures(size_t v) { m_num_features = v; }
+ std::size_t NumberOfFeatures() const { return m_num_features; }
+ void NumberOfFeatures(std::size_t v) { m_num_features = v; }
std::string Features() const { return m_features; }
void Features(const std::string& f) { m_features = f; }
@@ -89,10 +87,10 @@ public:
return -1;
}
- inline std::string getIndex(size_t idx) const {
+ inline std::string getIndex(std::size_t idx) const {
idx2name::const_iterator i = m_index_to_array_name.find(idx);
if (i != m_index_to_array_name.end())
- throw runtime_error("there is no entry at index " + idx);
+ throw std::runtime_error("there is no entry at index " + idx);
return i->second;
}
@@ -100,10 +98,10 @@ public:
return (m_index_to_feature_name.size() > 0) ? true : false;
}
- std::string getFeatureName(size_t idx) const {
+ std::string getFeatureName(std::size_t idx) const {
if (idx >= m_index_to_feature_name.size())
throw runtime_error("Error: you required an too big index");
- map<size_t, std::string>::const_iterator it = m_index_to_feature_name.find(idx);
+ std::map<std::size_t, std::string>::const_iterator it = m_index_to_feature_name.find(idx);
if (it == m_index_to_feature_name.end()) {
throw runtime_error("Error: specified id is unknown: " + idx);
} else {
@@ -111,16 +109,16 @@ public:
}
}
- size_t getFeatureIndex(const std::string& name) const {
- map<std::string, size_t>::const_iterator it = m_feature_name_to_index.find(name);
+ std::size_t getFeatureIndex(const std::string& name) const {
+ std::map<std::string, std::size_t>::const_iterator it = m_feature_name_to_index.find(name);
if (it == m_feature_name_to_index.end()) {
std::string msg = "Error: feature " + name + " is unknown. Known features: ";
- for (std::map<std::string, size_t>::const_iterator it = m_feature_name_to_index.begin(); it != m_feature_name_to_index.end(); it++) {
+ for (std::map<std::string, std::size_t>::const_iterator it = m_feature_name_to_index.begin(); it != m_feature_name_to_index.end(); it++) {
msg += it->first;
msg += ", ";
}
- throw runtime_error(msg);
+ throw std::runtime_error(msg);
}
return it->second;
}
diff --git a/mert/ScoreArray.cpp b/mert/ScoreArray.cpp
index 972bca0e7..83fa96ef0 100644
--- a/mert/ScoreArray.cpp
+++ b/mert/ScoreArray.cpp
@@ -10,6 +10,8 @@
#include "Util.h"
#include "FileStream.h"
+using namespace std;
+
ScoreArray::ScoreArray()
: m_num_scores(0), m_index("") {}
diff --git a/mert/ScoreArray.h b/mert/ScoreArray.h
index 384fdfff3..64d019daf 100644
--- a/mert/ScoreArray.h
+++ b/mert/ScoreArray.h
@@ -9,8 +9,6 @@
#ifndef MERT_SCORE_ARRAY_H_
#define MERT_SCORE_ARRAY_H_
-using namespace std;
-
#include <vector>
#include <iostream>
#include <string>
@@ -27,7 +25,7 @@ class ScoreArray
private:
scorearray_t m_array;
std::string m_score_type;
- size_t m_num_scores;
+ std::size_t m_num_scores;
// indexx to identify the utterance.
// It can differ from the index inside the vector.
@@ -43,18 +41,18 @@ public:
void setIndex(const std::string& value) { m_index = value; }
- ScoreStats& get(size_t i) { return m_array.at(i); }
+ ScoreStats& get(std::size_t i) { return m_array.at(i); }
- const ScoreStats& get(size_t i) const { return m_array.at(i); }
+ const ScoreStats& get(std::size_t i) const { return m_array.at(i); }
void add(const ScoreStats& e) { m_array.push_back(e); }
//ADDED BY TS
- void swap(size_t i, size_t j) {
+ void swap(std::size_t i, std::size_t j) {
std::swap(m_array[i], m_array[j]);
}
- void resize(size_t new_size) {
+ void resize(std::size_t new_size) {
m_array.resize(std::min(new_size, m_array.size()));
}
//END_ADDED
@@ -65,11 +63,11 @@ public:
void name(std::string &score_type) { m_score_type = score_type; }
- size_t size() const { return m_array.size(); }
+ std::size_t size() const { return m_array.size(); }
- size_t NumberOfScores() const { return m_num_scores; }
+ std::size_t NumberOfScores() const { return m_num_scores; }
- void NumberOfScores(size_t v) { m_num_scores = v; }
+ void NumberOfScores(std::size_t v) { m_num_scores = v; }
void savetxt(std::ostream* os, const std::string& score_type);
void savebin(std::ostream* os, const std::string& score_type);
@@ -77,8 +75,8 @@ public:
void save(const std::string &file, const std::string& score_type, bool bin=false);
void save(const std::string& score_type, bool bin=false);
- void loadtxt(std::istream* is, size_t n);
- void loadbin(std::istream* is, size_t n);
+ void loadtxt(std::istream* is, std::size_t n);
+ void loadbin(std::istream* is, std::size_t n);
void load(std::istream* is);
void load(const std::string &file);