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:
authorHieu Hoang <hieuhoang@gmail.com>2013-09-08 18:43:18 +0400
committerHieu Hoang <hieuhoang@gmail.com>2013-09-08 18:43:18 +0400
commit7214be82d45dbb2f113e3f0aec25b25d9cd76632 (patch)
treeb35fc778412e62af40421156faf2f2ff27f79983 /moses/ScoreComponentCollection.cpp
parent1adf7d05214526e98e8c6c31b090fbd3b485e4d4 (diff)
lattice decoding with sparse features
Diffstat (limited to 'moses/ScoreComponentCollection.cpp')
-rw-r--r--moses/ScoreComponentCollection.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp
index c9b4d1ea0..d3c31d625 100644
--- a/moses/ScoreComponentCollection.cpp
+++ b/moses/ScoreComponentCollection.cpp
@@ -8,6 +8,27 @@ using namespace std;
namespace Moses
{
+void ScorePair::PlusEquals(const ScorePair &other)
+{
+ PlusEquals(other.denseScores);
+ std::map<std::string, float>::const_iterator iter;
+ for (iter = other.sparseScores.begin(); iter != other.sparseScores.end(); ++iter) {
+ PlusEquals(iter->first, iter->second);
+ }
+}
+
+void ScorePair::PlusEquals(const std::string &key, float value)
+{
+ std::map<std::string, float>::iterator iter;
+ iter = sparseScores.find(key);
+ if (iter == sparseScores.end()) {
+ sparseScores[key] = value;
+ }
+ else {
+ float &existingval = iter->second;
+ existingval += value;
+ }
+}
ScoreComponentCollection::ScoreIndexMap ScoreComponentCollection::s_scoreIndexes;
size_t ScoreComponentCollection::s_denseVectorSize = 0;