summaryrefslogtreecommitdiff
path: root/decoder/aligner.cc
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-10-22 23:29:11 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-10-22 23:29:11 +0000
commitdd886ca6da84970ccb96b2f0155ff672e03f5b58 (patch)
tree78b5627347f3953539852cdd6b92053e844e87d4 /decoder/aligner.cc
parent550019457302ecaaec6f72e912013a6fa9f2da67 (diff)
handle translation from the null word
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@689 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/aligner.cc')
-rw-r--r--decoder/aligner.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/decoder/aligner.cc b/decoder/aligner.cc
index 92431be4..3f0c7347 100644
--- a/decoder/aligner.cc
+++ b/decoder/aligner.cc
@@ -24,8 +24,10 @@ void SourceEdgeCoveragesUsingParseIndices(const Hypergraph& g,
if (edge.rule_->EWords() == 0 || edge.rule_->FWords() == 0)
continue;
// aligned to NULL (crf ibm variant only)
- if (edge.prev_i_ == -1 || edge.i_ == -1)
+ if (edge.prev_i_ == -1 || edge.i_ == -1) {
+ cov.insert(-1);
continue;
+ }
assert(edge.j_ >= 0);
assert(edge.prev_j_ >= 0);
if (edge.Arity() == 0) {
@@ -211,7 +213,7 @@ void AlignerTools::WriteAlignment(const Lattice& src_lattice,
// figure out the src and reference size;
int src_size = src_sent.size();
int ref_size = trg_sent.size();
- Array2D<prob_t> align(src_size, ref_size, prob_t::Zero());
+ Array2D<prob_t> align(src_size + 1, ref_size, prob_t::Zero());
for (int c = 0; c < g->edges_.size(); ++c) {
const prob_t& p = edge_posteriors[c];
const set<int>& srcs = src_cov[c];
@@ -220,7 +222,7 @@ void AlignerTools::WriteAlignment(const Lattice& src_lattice,
si != srcs.end(); ++si) {
for (set<int>::const_iterator ti = trgs.begin();
ti != trgs.end(); ++ti) {
- align(*si, *ti) += p;
+ align(*si + 1, *ti) += p;
}
}
}
@@ -234,12 +236,12 @@ void AlignerTools::WriteAlignment(const Lattice& src_lattice,
for (int j = 0; j < ref_size; ++j) {
if (use_soft_threshold) {
threshold = prob_t::Zero();
- for (int i = 0; i < src_size; ++i)
+ for (int i = 0; i <= src_size; ++i)
if (align(i, j) > threshold) threshold = align(i, j);
//threshold *= prob_t(0.99);
}
for (int i = 0; i < src_size; ++i)
- grid(i, j) = align(i, j) >= threshold;
+ grid(i, j) = align(i+1, j) >= threshold;
}
if (out == &cout) {
// TODO need to do some sort of verbose flag