From ded34c668ca87b9e0a0ebca68944c6648602593a Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 28 May 2012 00:19:10 -0400 Subject: cache metric computation in pro --- training/candidate_set.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'training/candidate_set.h') diff --git a/training/candidate_set.h b/training/candidate_set.h index e2b0b1ba..824a4de2 100644 --- a/training/candidate_set.h +++ b/training/candidate_set.h @@ -4,29 +4,27 @@ #include #include +#include "ns.h" #include "wordid.h" #include "sparse_vector.h" class Hypergraph; -struct SegmentEvaluator; -struct EvaluationMetric; namespace training { struct Candidate { - Candidate() : g_(-100.0f) {} - Candidate(const std::vector& e, const SparseVector& fm) : ewords(e), fmap(fm), g_(-100.0f) {} + Candidate() {} + Candidate(const std::vector& e, const SparseVector& fm) : + ewords(e), + fmap(fm) {} std::vector ewords; SparseVector fmap; - double g(const SegmentEvaluator& scorer, const EvaluationMetric* metric) const; + SufficientStats score_stats; void swap(Candidate& other) { - std::swap(g_, other.g_); + score_stats.swap(other.score_stats); ewords.swap(other.ewords); fmap.swap(other.fmap); } - private: - mutable float g_; - //SufficientStats score_stats; }; // represents some kind of collection of translation candidates, e.g. @@ -39,7 +37,7 @@ class CandidateSet { void ReadFromFile(const std::string& file); void WriteToFile(const std::string& file) const; - void AddKBestCandidates(const Hypergraph& hg, size_t kbest_size); + void AddKBestCandidates(const Hypergraph& hg, size_t kbest_size, const SegmentEvaluator* scorer = NULL); // TODO add code to do unique k-best // TODO add code to draw k samples -- cgit v1.2.3