summaryrefslogtreecommitdiff
path: root/utils/weights.cc
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-10-20 03:04:14 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-10-20 03:04:14 +0000
commit44b9b1b1021f946d08cc65baab919e2a6de787c8 (patch)
tree8168a0f73c255998cc71ac51e4d9d43e57504195 /utils/weights.cc
parent6f95b5bf05c13ee0ced81eb59751b530fbcc8189 (diff)
forgot what this is
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@683 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/weights.cc')
-rw-r--r--utils/weights.cc8
1 files 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<string>* 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<string>* 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);