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
commit083e28a2694df51a4631d81347c45f57a5182560 (patch)
tree8f1fd61cb8273ece5a418a2be5af04766eddbaa4 /decoder
parent46882b48148ec36d4eac7a94a3b2bf453ffb0828 (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) << " ||| ";