summaryrefslogtreecommitdiff
path: root/vest/scorer.h
diff options
context:
space:
mode:
Diffstat (limited to 'vest/scorer.h')
-rw-r--r--vest/scorer.h44
1 files changed, 25 insertions, 19 deletions
diff --git a/vest/scorer.h b/vest/scorer.h
index cc6b7335..29ba5377 100644
--- a/vest/scorer.h
+++ b/vest/scorer.h
@@ -3,9 +3,14 @@
#include <vector>
#include <string>
#include <boost/shared_ptr.hpp>
-
+//TODO: use intrusive shared_ptr in Score (because there are many of them on ErrorSurfaces)
#include "wordid.h"
+class Score;
+class SentenceScorer;
+typedef boost::shared_ptr<Score> ScoreP;
+typedef boost::shared_ptr<SentenceScorer> ScorerP;
+
class ViterbiEnvelope;
class ErrorSurface;
class Hypergraph; // needed for alignment
@@ -16,7 +21,6 @@ std::string StringFromScoreType(ScoreType st);
class Score {
public:
- typedef boost::shared_ptr<Score> ScoreP;
virtual ~Score();
virtual float ComputeScore() const = 0;
virtual float ComputePartialScore() const =0;
@@ -29,21 +33,19 @@ class Score {
virtual void PlusEquals(const Score& rhs, const float scale) = 0;
virtual void PlusEquals(const Score& rhs) = 0;
virtual void PlusPartialEquals(const Score& rhs, int oracle_e_cover, int oracle_f_cover, int src_len) = 0;
- virtual void Subtract(const Score& rhs, Score* res) const = 0;
- virtual Score* GetZero() const = 0;
- virtual Score* GetOne() const = 0;
+ virtual void Subtract(const Score& rhs, Score *res) const = 0;
+ virtual ScoreP GetZero() const = 0;
+ virtual ScoreP GetOne() 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;
- static Score* GetZero(ScoreType type);
- static Score* GetOne(ScoreType type);
+ static ScoreP GetZero(ScoreType type);
+ static ScoreP GetOne(ScoreType type);
};
class SentenceScorer {
public:
- typedef boost::shared_ptr<Score> ScoreP;
- typedef boost::shared_ptr<SentenceScorer> ScorerP;
typedef std::vector<WordID> Sentence;
typedef std::vector<Sentence> Sentences;
std::string desc;
@@ -52,14 +54,14 @@ class SentenceScorer {
std::string verbose_desc() const;
virtual float ComputeRefLength(const Sentence& hyp) const; // default: avg of refs.length
virtual ~SentenceScorer();
- virtual Score* GetOne() const;
- virtual Score* GetZero() const;
+ virtual ScoreP GetOne() const;
+ virtual ScoreP GetZero() const;
void ComputeErrorSurface(const ViterbiEnvelope& ve, ErrorSurface* es, const ScoreType type, const Hypergraph& hg) const;
- virtual Score* ScoreCandidate(const Sentence& hyp) const = 0;
- virtual Score* ScoreCCandidate(const Sentence& hyp) const =0;
+ virtual ScoreP ScoreCandidate(const Sentence& hyp) const = 0;
+ virtual ScoreP ScoreCCandidate(const Sentence& hyp) const =0;
virtual const std::string* GetSource() const;
- static Score* CreateScoreFromString(const ScoreType type, const std::string& in);
- static SentenceScorer* CreateSentenceScorer(const ScoreType type,
+ static ScoreP CreateScoreFromString(const ScoreType type, const std::string& in);
+ static ScorerP CreateSentenceScorer(const ScoreType type,
const std::vector<Sentence >& refs,
const std::string& src = "");
};
@@ -71,19 +73,23 @@ class DocScorer {
DocScorer() { }
void Init(const ScoreType type,
const std::vector<std::string>& ref_files,
- const std::string& src_file = "");
+ const std::string& src_file = "",
+ bool verbose=false
+ );
DocScorer(const ScoreType type,
const std::vector<std::string>& ref_files,
- const std::string& src_file = "")
+ const std::string& src_file = "",
+ bool verbose=false
+ )
{
- Init(type,ref_files,src_file);
+ Init(type,ref_files,src_file,verbose);
}
int size() const { return scorers_.size(); }
- typedef boost::shared_ptr<SentenceScorer> ScorerP;
ScorerP operator[](size_t i) const { return scorers_[i]; }
private:
std::vector<ScorerP> scorers_;
};
+
#endif