diff options
author | Patrick Simianer <p@simianer.de> | 2015-02-01 20:14:37 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-02-01 20:14:37 +0100 |
commit | 220d2ff82d8d7f02b1b93711fe418015026ae1a6 (patch) | |
tree | b977d5dbb0bf840b9163f24d156c0d37b7ed8214 /training | |
parent | b31708e1066ff699c7c06d1edb7c8223b84d62cd (diff) |
dtrain: rm 'check' and ksampler
Diffstat (limited to 'training')
-rw-r--r-- | training/dtrain/ksampler.h | 60 | ||||
-rw-r--r-- | training/dtrain/pairs.h (renamed from training/dtrain/pairsampling.h) | 0 | ||||
-rw-r--r-- | training/dtrain/sample.h (renamed from training/dtrain/kbestget.h) | 0 |
3 files changed, 0 insertions, 60 deletions
diff --git a/training/dtrain/ksampler.h b/training/dtrain/ksampler.h deleted file mode 100644 index 9eedc74f..00000000 --- a/training/dtrain/ksampler.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _DTRAIN_KSAMPLER_H_ -#define _DTRAIN_KSAMPLER_H_ - -#include "hg_sampler.h" - -namespace dtrain -{ - - -bool -cmp_hyp_by_model_d(ScoredHyp a, ScoredHyp b) -{ - return a.model > b.model; -} - -struct KSampler : public HypSampler -{ - const unsigned k_; - 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) - { - src_len_ = smeta.GetSourceLength(); - ScoredSamples(*hg); - } - - vector<ScoredHyp>* GetSamples() { return &s_; } - - void ScoredSamples(const Hypergraph& forest) { - s_.clear(); sz_ = f_count_ = 0; - std::vector<HypergraphSampler::Hypothesis> samples; - HypergraphSampler::sample_hypotheses(forest, k_, prng_, &samples); - for (unsigned i = 0; i < k_; ++i) { - ScoredHyp h; - h.w = samples[i].words; - h.f = samples[i].fmap; - h.model = log(samples[i].model_score); - h.rank = i; - h.score = scorer_->Score(h.w, *refs_, i, src_len_); - s_.push_back(h); - sz_++; - f_count_ += h.f.size(); - } - sort(s_.begin(), s_.end(), cmp_hyp_by_model_d); - for (unsigned i = 0; i < s_.size(); i++) s_[i].rank = i; - } -}; - - -} // namespace - -#endif - diff --git a/training/dtrain/pairsampling.h b/training/dtrain/pairs.h index fd08be8c..fd08be8c 100644 --- a/training/dtrain/pairsampling.h +++ b/training/dtrain/pairs.h diff --git a/training/dtrain/kbestget.h b/training/dtrain/sample.h index 25f02273..25f02273 100644 --- a/training/dtrain/kbestget.h +++ b/training/dtrain/sample.h |