diff options
-rw-r--r-- | mert/BleuScorer.cpp | 4 | ||||
-rw-r--r-- | mert/CderScorer.cpp | 2 | ||||
-rw-r--r-- | mert/Data.cpp | 4 | ||||
-rw-r--r-- | mert/FeatureStats.cpp | 2 | ||||
-rw-r--r-- | mert/Point.cpp | 2 | ||||
-rwxr-xr-x | mert/mert.cpp | 6 | ||||
-rw-r--r-- | mert/pro.cpp | 2 |
7 files changed, 11 insertions, 11 deletions
diff --git a/mert/BleuScorer.cpp b/mert/BleuScorer.cpp index 67692eef7..45bd635bb 100644 --- a/mert/BleuScorer.cpp +++ b/mert/BleuScorer.cpp @@ -142,7 +142,7 @@ 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 = (float)total/_reflengths[sid].size(); + float mean = static_cast<float>(total) /_reflengths[sid].size(); stats.push_back(mean); } else if (_refLengthStrategy == BLEU_CLOSEST) { int min_diff = INT_MAX; @@ -196,7 +196,7 @@ float BleuScorer::calculateScore(const vector<int>& comps) const } logbleu /= kLENGTH; - float brevity = 1.0 - (float)comps[kLENGTH*2]/comps[1];//reflength divided by test length + const float brevity = 1.0 - static_cast<float>(comps[kLENGTH*2]) / comps[1];//reflength divided by test length if (brevity < 0.0) { logbleu += brevity; } diff --git a/mert/CderScorer.cpp b/mert/CderScorer.cpp index fc8d69f5f..8c83ac085 100644 --- a/mert/CderScorer.cpp +++ b/mert/CderScorer.cpp @@ -50,7 +50,7 @@ float CderScorer::calculateScore(const vector<int>& comps) const throw runtime_error("Size of stat vector for CDER is not 2"); } - return 1 - (comps[0] / (float) comps[1]); + return 1 - (comps[0] / static_cast<float>(comps[1])); } vector<int> CderScorer::computeCD(const sent_t& cand, const sent_t& ref) const diff --git a/mert/Data.cpp b/mert/Data.cpp index a3c6fc314..3e723f8be 100644 --- a/mert/Data.cpp +++ b/mert/Data.cpp @@ -255,8 +255,8 @@ void Data::createShards(size_t shard_count, float shard_size, const string& scor vector<size_t> shard_contents; if (shard_size == 0) { //split into roughly equal size shards - size_t shard_start = floor(0.5 + shard_id * (float)data_size / shard_count); - size_t shard_end = floor(0.5 + (shard_id+1) * (float)data_size / shard_count); + const size_t shard_start = floor(0.5 + shard_id * static_cast<float>(data_size) / shard_count); + const size_t shard_end = floor(0.5 + (shard_id + 1) * static_cast<float>(data_size) / shard_count); for (size_t i = shard_start; i < shard_end; ++i) { shard_contents.push_back(i); } diff --git a/mert/FeatureStats.cpp b/mert/FeatureStats.cpp index a8f0f478b..0fe003158 100644 --- a/mert/FeatureStats.cpp +++ b/mert/FeatureStats.cpp @@ -46,7 +46,7 @@ void SparseVector::set(const string& name, FeatureStatsType value) { void SparseVector::write(ostream& out, const string& sep) const { for (fvector_t::const_iterator i = fvector_.begin(); i != fvector_.end(); ++i) { - if (abs((float)(i->second)) < 0.00001) continue; + if (abs(i->second) < 0.00001) continue; string name = id2name_[i->first]; out << name << sep << i->second << " "; } diff --git a/mert/Point.cpp b/mert/Point.cpp index 322f10f77..f298647dd 100644 --- a/mert/Point.cpp +++ b/mert/Point.cpp @@ -54,7 +54,7 @@ void Point::Randomize() CHECK(m_max.size()==Point::dim); for (unsigned int i=0; i<size(); i++) { operator[](i) = m_min[i] + - (float)random()/(float)RAND_MAX * (float)(m_max[i]-m_min[i]); + static_cast<float>(random()) / static_cast<float>(RAND_MAX) * (m_max[i] - m_min[i]); } } diff --git a/mert/mert.cpp b/mert/mert.cpp index 2384f1ede..58214f30b 100755 --- a/mert/mert.cpp +++ b/mert/mert.cpp @@ -459,8 +459,8 @@ int main(int argc, char **argv) } } - mean /= (float)option.ntry; - var /= (float)option.ntry; + mean /= static_cast<float>(option.ntry); + var /= static_cast<float>(option.ntry); var = sqrt(abs(var - mean * mean)); if (verboselevel() > 1) { @@ -481,7 +481,7 @@ int main(int argc, char **argv) cerr << "bestP: " << finalP << endl; // L1-Normalization of the best Point - if ((int)to_optimize.size() == option.pdim) { + if (static_cast<int>(to_optimize.size()) == option.pdim) { finalP.NormalizeL1(); } diff --git a/mert/pro.cpp b/mert/pro.cpp index aa92d4373..a18e7a117 100644 --- a/mert/pro.cpp +++ b/mert/pro.cpp @@ -76,7 +76,7 @@ static float sentenceLevelBleuPlusOne(const vector<float>& stats) { logbleu += log(stats[2*j]+1) - log(stats[2*j+1]+1); } logbleu /= bleu_order; - float brevity = 1.0 - (float)stats[(bleu_order*2)]/stats[1]; + const float brevity = 1.0 - static_cast<float>(stats[(bleu_order*2)]) / stats[1]; if (brevity < 0.0) { logbleu += brevity; } |