Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-01 11:59:48 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2012-02-01 11:59:48 +0400
commit3c04b7e826df624d269df499433b9b19d3611dae (patch)
tree8c39cdd09111961e54c253a68217ffd2b728ece6 /mert/mert.cpp
parent1bafc99ea22ea73a4f4fab5b64f1907b17d7718a (diff)
Create a function to save final weights to a file.
Diffstat (limited to 'mert/mert.cpp')
-rwxr-xr-xmert/mert.cpp19
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();