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:
authorBarry Haddow <barry.haddow@gmail.com>2014-08-06 14:38:51 +0400
committerBarry Haddow <barry.haddow@gmail.com>2014-08-06 14:38:51 +0400
commitff188c454a14f112d7de1df65f600574fc033713 (patch)
tree339243f2110c6006d1801eb7a3b3ea6b2fdd1d94 /moses/ScoreComponentCollection.cpp
parent6549d24d35911a013f6b38f8dccbedb953210791 (diff)
Sparse features trainable with hg mira
(In phrase-based Moses)
Diffstat (limited to 'moses/ScoreComponentCollection.cpp')
-rw-r--r--moses/ScoreComponentCollection.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp
index 52ec00dd4..d4df4742e 100644
--- a/moses/ScoreComponentCollection.cpp
+++ b/moses/ScoreComponentCollection.cpp
@@ -179,25 +179,31 @@ void ScoreComponentCollection::SparseL2Regularize(float lambda)
m_scores.sparseL2regularize(lambda);
}
-void ScoreComponentCollection::Save(ostream& out) const
+void ScoreComponentCollection::Save(ostream& out, bool multiline) const
{
+ string sep = " ";
+ string linesep = "\n";
+ if (!multiline) {
+ sep = "=";
+ linesep = " ";
+ }
ScoreIndexMap::const_iterator iter = s_scoreIndexes.begin();
for (; iter != s_scoreIndexes.end(); ++iter ) {
string name = iter->first->GetScoreProducerDescription();
IndexPair ip = iter->second; // feature indices
if (ip.second-ip.first == 1) {
- out << name << " " << m_scores[ip.first] << endl;
+ out << name << sep << m_scores[ip.first] << linesep;
} else {
for (size_t i=ip.first; i < ip.second; ++i) {
ostringstream fullname;
fullname << name << "_" << (i + 1 - ip.first);
- out << fullname.str() << " " << m_scores[i] << endl;
+ out << fullname.str() << sep << m_scores[i] << linesep;
}
}
}
// write sparse features
- m_scores.write(out);
+ m_scores.write(out,sep);
}
void ScoreComponentCollection::Save(const string& filename) const