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 21:22:55 +0400
committerHieu Hoang <hieuhoang@gmail.com>2013-09-08 21:22:55 +0400
commit16cfc786a8f535de225c450cca16e82304b5de8c (patch)
tree4a257c7ea53d32ca93f7a32c432d79a74728c45d /moses/WordLattice.cpp
parent42fc86b259498d99d75e4fd956e74ecd8888440a (diff)
lattice decoding with sparse features
Diffstat (limited to 'moses/WordLattice.cpp')
-rw-r--r--moses/WordLattice.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/moses/WordLattice.cpp b/moses/WordLattice.cpp
index ff1d25e66..c457b4e2b 100644
--- a/moses/WordLattice.cpp
+++ b/moses/WordLattice.cpp
@@ -1,3 +1,4 @@
+#include <map>
#include "StaticData.h"
#include "WordLattice.h"
#include "PCNTools.h"
@@ -21,9 +22,19 @@ void WordLattice::Print(std::ostream& out) const
out<<i<<" -- ";
for(size_t j=0; j<data[i].size(); ++j) {
out<<"("<<data[i][j].first.ToString()<<", ";
- for(std::vector<float>::const_iterator scoreIterator = data[i][j].second.begin(); scoreIterator<data[i][j].second.end(); scoreIterator++) {
- out<<*scoreIterator<<", ";
+
+ // dense
+ std::vector<float>::const_iterator iterDense;
+ for(iterDense = data[i][j].second.denseScores.begin(); iterDense < data[i][j].second.denseScores.end(); ++iterDense) {
+ out<<", "<<*iterDense;
+ }
+
+ // sparse
+ std::map<StringPiece, float>::const_iterator iterSparse;
+ for(iterSparse = data[i][j].second.sparseScores.begin(); iterSparse != data[i][j].second.sparseScores.end(); ++iterSparse) {
+ out << ", " << iterSparse->first << "=" << iterSparse->second;
}
+
out << GetColumnIncrement(i,j) << ") ";
}
@@ -74,13 +85,16 @@ int WordLattice::InitializeFromPCNDataType(const PCN::CN& cn, const std::vector<
//*probsIterator = 1.0f;
}
}
- data[i][j].second.push_back(std::max(static_cast<float>(log(*probsIterator)), LOWEST_SCORE));
+
+ float score = std::max(static_cast<float>(log(*probsIterator)), LOWEST_SCORE);
+ ScorePair &scorePair = data[i][j].second;
+ scorePair.denseScores.push_back(score);
}
//store 'real' word count in last feature if we have one more weight than we do arc scores and not epsilon
if (addRealWordCount) {
//only add count if not epsilon
float value = (alt.m_word=="" || alt.m_word==EPSILON) ? 0.0f : -1.0f;
- data[i][j].second.push_back(value);
+ data[i][j].second.denseScores.push_back(value);
}
String2Word(alt.m_word, data[i][j]. first, factorOrder);
next_nodes[i][j] = alt.m_next;