diff options
Diffstat (limited to 'dtrain/ksampler.h')
-rw-r--r-- | dtrain/ksampler.h | 6 |
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); } } |