mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 13:23:25 +03:00
Fix using namespace "std" before including headers in *.h.
This commit is contained in:
parent
89f23cfc08
commit
4b5fe180ed
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Util.h"
|
||||
#include "FileStream.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ScoreArray::ScoreArray()
|
||||
: m_num_scores(0), m_index("") {}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user