summaryrefslogtreecommitdiff
path: root/dtrain/ksampler.h
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-04-27 01:54:47 +0200
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-04-27 01:54:47 +0200
commita94a2016915d91d01a102c56b86a54e5fe6e647a (patch)
tree8f44adfea95326df3fbdde7084aabb32a2de0eb1 /dtrain/ksampler.h
parent35527b4691c6ca08694e2235e1c469f155a31c47 (diff)
fix approx. BLEU of (Chiang et al. '08)
Diffstat (limited to 'dtrain/ksampler.h')
-rw-r--r--dtrain/ksampler.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/dtrain/ksampler.h b/dtrain/ksampler.h
index eb4813ab..0783f98b 100644
--- a/dtrain/ksampler.h
+++ b/dtrain/ksampler.h
@@ -15,13 +15,15 @@ struct KSampler : public HypSampler
vector<ScoredHyp> s_;
MT19937* prng_;
score_t (*scorer)(NgramCounts&, const unsigned, const unsigned, unsigned, vector<score_t>);
+ unsigned src_len_;
explicit KSampler(const unsigned k, MT19937* prng) :
k_(k), prng_(prng) {}
virtual void
- NotifyTranslationForest(const SentenceMetadata& /*smeta*/, Hypergraph* hg)
+ NotifyTranslationForest(const SentenceMetadata& smeta, Hypergraph* hg)
{
+ src_len_ = smeta.GetSourceLength();
ScoredSamples(*hg);
}
@@ -37,7 +39,7 @@ struct KSampler : public HypSampler
h.f = samples[i].fmap;
h.model = log(samples[i].model_score);
h.rank = i;
- h.score = scorer_->Score(h.w, *ref_, i);
+ h.score = scorer_->Score(h.w, *ref_, i, src_len_);
s_.push_back(h);
}
}