diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-02-01 11:59:48 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-02-01 11:59:48 +0400 |
commit | 380f550cf3d2b1150a6868ed6725ce55c1687070 (patch) | |
tree | 8c39cdd09111961e54c253a68217ffd2b728ece6 | |
parent | 2a7d2a395f2c3b00efc69c6ef54c2ac5d8476e17 (diff) |
Create a function to save final weights to a file.
-rwxr-xr-x | mert/mert.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/mert/mert.cpp b/mert/mert.cpp index 335b5c7ea..2384f1ede 100755 --- a/mert/mert.cpp +++ b/mert/mert.cpp @@ -80,6 +80,19 @@ class OptimizationTask : public Moses::Task { statscore_t m_score; }; +bool WriteFinalWeights(const char* filename, const Point& point) { + ofstream ofs(filename); + if (!ofs) { + cerr << "Cannot open " << filename << endl; + return false; + } + + ofs << point << endl; + + return true; +} + + void usage(int ret) { cerr << "usage: mert -d <dimensions> (mandatory)" << endl; @@ -473,8 +486,10 @@ int main(int argc, char **argv) } cerr << "Best point: " << finalP << " => " << final << endl; - ofstream res(kOutputFile); - res << finalP << endl; + + if (!WriteFinalWeights(kOutputFile, finalP)) { + cerr << "Warning: Failed to write the final point" << endl; + } for (size_t i = 0; i < allTasks.size(); ++i) { allTasks[i][0]->resetOptimizer(); |