mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Change casts to C++ style casts.
This commit is contained in:
parent
142342f8be
commit
3ef03a77c4
@ -142,18 +142,21 @@ void BleuScorer::prepareStats(size_t sid, const string& text, ScoreStats& entry)
|
||||
for (size_t i = 0; i < _reflengths[sid].size(); ++i) {
|
||||
total += _reflengths[sid][i];
|
||||
}
|
||||
float mean = static_cast<float>(total) /_reflengths[sid].size();
|
||||
const float mean = static_cast<float>(total) /_reflengths[sid].size();
|
||||
stats.push_back(mean);
|
||||
} else if (_refLengthStrategy == BLEU_CLOSEST) {
|
||||
int min_diff = INT_MAX;
|
||||
int min_idx = 0;
|
||||
for (size_t i = 0; i < _reflengths[sid].size(); ++i) {
|
||||
int reflength = _reflengths[sid][i];
|
||||
if (abs(reflength-(int)length) < abs(min_diff)) { //look for the closest reference
|
||||
min_diff = reflength-length;
|
||||
const int reflength = _reflengths[sid][i];
|
||||
const int diff = reflength - static_cast<int>(length);
|
||||
const int absolute_diff = abs(diff) - abs(min_diff);
|
||||
|
||||
if (absolute_diff < 0) { //look for the closest reference
|
||||
min_diff = diff;
|
||||
min_idx = i;
|
||||
} else if (abs(reflength-(int)length) == abs(min_diff)) { // if two references has the same closest length, take the shortest
|
||||
if (reflength < (int)_reflengths[sid][min_idx]) {
|
||||
} else if (absolute_diff == 0) { // if two references has the same closest length, take the shortest
|
||||
if (reflength < static_cast<int>(_reflengths[sid][min_idx])) {
|
||||
min_idx = i;
|
||||
}
|
||||
}
|
||||
|
@ -52,11 +52,12 @@ public:
|
||||
return array_.at(idx);
|
||||
}
|
||||
|
||||
inline bool exists(const std::string& sent_idx) {
|
||||
inline bool exists(const std::string& sent_idx) const {
|
||||
return exists(getIndex(sent_idx));
|
||||
}
|
||||
inline bool exists(int sent_idx) {
|
||||
return (sent_idx>-1 && sent_idx<(int) array_.size())?true:false;
|
||||
|
||||
inline bool exists(int sent_idx) const {
|
||||
return (sent_idx > -1 && sent_idx < static_cast<int>(array_.size())) ? true : false;
|
||||
}
|
||||
|
||||
inline FeatureStats& get(size_t i, size_t j) {
|
||||
|
@ -57,8 +57,9 @@ public:
|
||||
inline bool exists(const std::string& sent_idx) const {
|
||||
return exists(getIndex(sent_idx));
|
||||
}
|
||||
|
||||
inline bool exists(int sent_idx) const {
|
||||
return (sent_idx > -1 && sent_idx < (int)array_.size()) ? true : false;
|
||||
return (sent_idx > -1 && sent_idx < static_cast<int>(array_.size())) ? true : false;
|
||||
}
|
||||
|
||||
inline ScoreStats& get(size_t i, size_t j) {
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
virtual void prepareStats(const string& sindex, const string& text, ScoreStats& entry) {
|
||||
|
||||
// cerr << sindex << endl;
|
||||
this->prepareStats((size_t) atoi(sindex.c_str()), text, entry);
|
||||
this->prepareStats(static_cast<size_t>(atoi(sindex.c_str())), text, entry);
|
||||
//cerr << text << std::endl;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ protected:
|
||||
encodings_it encoding = _encodings.find(token);
|
||||
int encoded_token;
|
||||
if (encoding == _encodings.end()) {
|
||||
encoded_token = (int)_encodings.size();
|
||||
encoded_token = static_cast<int>(_encodings.size());
|
||||
_encodings[token] = encoded_token;
|
||||
//cerr << encoded_token << "(n) ";
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user