summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-12-01 04:49:31 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-12-01 04:49:31 +0000
commitca83fbe4c043b2e4e18a21f91e74dfa922eda44e (patch)
tree97f7e593fc04f3ac03ca46544faa6125030293cd /decoder
parentba99c3a4e5b73d955c2fb48cd16d5be2fbdd968e (diff)
justify
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@738 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rw-r--r--decoder/aligner.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/decoder/aligner.cc b/decoder/aligner.cc
index 3f0c7347..43d4e0ce 100644
--- a/decoder/aligner.cc
+++ b/decoder/aligner.cc
@@ -1,12 +1,14 @@
#include "aligner.h"
+#include <cstdio>
+#include <set>
+
#include "array2d.h"
#include "hg.h"
#include "sentence_metadata.h"
#include "inside_outside.h"
#include "viterbi.h"
#include "alignment_pharaoh.h"
-#include <set>
using namespace std;
@@ -152,6 +154,22 @@ struct TransitionEventWeightFunction {
}
};
+inline void WriteProbGrid(const Array2D<prob_t>& m, ostream* pos) {
+ ostream& os = *pos;
+ char b[1024];
+ for (int i=0; i<m.width(); ++i) {
+ for (int j=0; j<m.height(); ++j) {
+ if (m(i,j) == prob_t::Zero()) {
+ os << "\t---X---";
+ } else {
+ snprintf(b, 1024, "%0.5f", static_cast<double>(m(i,j)));
+ os << '\t' << b;
+ }
+ }
+ os << '\n';
+ }
+}
+
// this code is rather complicated since it must deal with generating alignments
// when lattices are specified as input as well as with models that do not generate
// full sentence pairs (like lexical alignment models)
@@ -245,7 +263,7 @@ void AlignerTools::WriteAlignment(const Lattice& src_lattice,
}
if (out == &cout) {
// TODO need to do some sort of verbose flag
- cerr << align << endl;
+ WriteProbGrid(align, &cerr);
cerr << grid << endl;
}
(*out) << TD::GetString(src_sent) << " ||| " << TD::GetString(trg_sent) << " ||| ";