diff options
author | Chris Dyer <redpony@gmail.com> | 2009-12-03 16:49:30 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2009-12-03 16:49:30 -0500 |
commit | 9fae7b75c64f4dfb6e45ff8f2ec61b597f37d225 (patch) | |
tree | 61a187c4fa6db8527f90f3060d18357f7b60b44a /vest/scorer.h | |
parent | 671c21451542e2dd20e45b4033d44d8e8735f87b (diff) |
fix build in new layout
Diffstat (limited to 'vest/scorer.h')
-rw-r--r-- | vest/scorer.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vest/scorer.h b/vest/scorer.h new file mode 100644 index 00000000..b0bba640 --- /dev/null +++ b/vest/scorer.h @@ -0,0 +1,51 @@ +#ifndef SCORER_H_ +#define SCORER_H_ + +#include <vector> +#include <string> + +#include "wordid.h" + +class ViterbiEnvelope; +class ErrorSurface; + +enum ScoreType { IBM_BLEU, NIST_BLEU, Koehn_BLEU, TER, BLEU_minus_TER_over_2, SER }; +ScoreType ScoreTypeFromString(const std::string& st); + +class Score { + public: + virtual ~Score(); + virtual float ComputeScore() const = 0; + virtual void ScoreDetails(std::string* details) const = 0; + virtual void PlusEquals(const Score& rhs) = 0; + virtual void Subtract(const Score& rhs, Score* res) const = 0; + virtual Score* GetZero() const = 0; + virtual bool IsAdditiveIdentity() const = 0; // returns true if adding this delta + // to another score results in no score change + // under any circumstances + virtual void Encode(std::string* out) const = 0; +}; + +class SentenceScorer { + public: + virtual ~SentenceScorer(); + void ComputeErrorSurface(const ViterbiEnvelope& ve, ErrorSurface* es) const; + virtual Score* ScoreCandidate(const std::vector<WordID>& hyp) const = 0; + static Score* CreateScoreFromString(const ScoreType type, const std::string& in); + static SentenceScorer* CreateSentenceScorer(const ScoreType type, + const std::vector<std::vector<WordID> >& refs); +}; + +class DocScorer { + public: + ~DocScorer(); + DocScorer( + const ScoreType type, + const std::vector<std::string>& ref_files); + int size() const { return scorers_.size(); } + const SentenceScorer* operator[](size_t i) const { return scorers_[i]; } + private: + std::vector<SentenceScorer*> scorers_; +}; + +#endif |