From 31b5d03c75b5d07afb54251e39fcf3e610d16141 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 9 Feb 2014 20:50:41 -0500 Subject: adaptive hope-fear learner --- training/utils/candidate_set.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'training/utils/candidate_set.cc') diff --git a/training/utils/candidate_set.cc b/training/utils/candidate_set.cc index 33dae9a3..36f5b271 100644 --- a/training/utils/candidate_set.cc +++ b/training/utils/candidate_set.cc @@ -171,4 +171,19 @@ void CandidateSet::AddKBestCandidates(const Hypergraph& hg, size_t kbest_size, c Dedup(); } +void CandidateSet::AddUniqueKBestCandidates(const Hypergraph& hg, size_t kbest_size, const SegmentEvaluator* scorer) { + typedef KBest::KBestDerivations, ESentenceTraversal, KBest::FilterUnique> K; + K kbest(hg, kbest_size); + + for (unsigned i = 0; i < kbest_size; ++i) { + const K::Derivation* d = + kbest.LazyKthBest(hg.nodes_.size() - 1, i); + if (!d) break; + cs.push_back(Candidate(d->yield, d->feature_values)); + if (scorer) + scorer->Evaluate(d->yield, &cs.back().eval_feats); + } + Dedup(); +} + } -- cgit v1.2.3