From 0a4cfe35aa687428d5e9f001a2d9e9c16904f52a Mon Sep 17 00:00:00 2001 From: redpony Date: Wed, 20 Oct 2010 03:04:14 +0000 Subject: forgot what this is git-svn-id: https://ws10smt.googlecode.com/svn/trunk@683 ec762483-ff6d-05da-a07a-a48fb63a330f --- utils/weights.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/weights.cc b/utils/weights.cc index 53089f89..b994a2fe 100644 --- a/utils/weights.cc +++ b/utils/weights.cc @@ -15,9 +15,9 @@ void Weights::InitFromFile(const std::string& filename, vector* feature_ assert(in); int weight_count = 0; bool fl = false; + string buf; + double val = 0; while (in) { - double val = 0; - string buf; getline(in, buf); if (buf.size() == 0) continue; if (buf[0] == '#') continue; @@ -27,12 +27,12 @@ void Weights::InitFromFile(const std::string& filename, vector* feature_ while(start < buf.size() && buf[start] == ' ') ++start; int end = 0; while(end < buf.size() && buf[end] != ' ') ++end; - int fid = FD::Convert(buf.substr(start, end - start)); + const int fid = FD::Convert(buf.substr(start, end - start)); while(end < buf.size() && buf[end] == ' ') ++end; val = strtod(&buf.c_str()[end], NULL); if (isnan(val)) { cerr << FD::Convert(fid) << " has weight NaN!\n"; - abort(); + abort(); } if (wv_.size() <= fid) wv_.resize(fid + 1); -- cgit v1.2.3