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
commitc0565f28cd45ba7d6f478c1dc36a6f1b8aa47669 (patch)
tree4e277bc68f6c9797d55417ed30adc97668eacbe7 /decoder/aligner.cc
parentaf58383779c70d0caa29cbcacf2bd13d4f072333 (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