summaryrefslogtreecommitdiff
path: root/dtrain/score.h
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2011-09-26 21:51:52 +0200
committerPatrick Simianer <p@simianer.de>2011-09-26 21:51:52 +0200
commit8bb00a2a2775442418f1cb7c041f7cba5d6e0d42 (patch)
tree7ac3d9f6941ef1f5142d009c485f2b21c33648de /dtrain/score.h
parenta433961e78a958d25a6d708bfd89e9655d1217c7 (diff)
got rid of scoring loop
Diffstat (limited to 'dtrain/score.h')
-rw-r--r--dtrain/score.h44
1 files changed, 6 insertions, 38 deletions
diff --git a/dtrain/score.h b/dtrain/score.h
index f87d708c..9af56ef9 100644
--- a/dtrain/score.h
+++ b/dtrain/score.h
@@ -1,16 +1,8 @@
#ifndef _DTRAIN_SCORE_H_
#define _DTRAIN_SCORE_H_
-#include <iostream>
-#include <vector>
-#include <map>
-#include <cassert>
-#include <cmath>
-
#include "kbestget.h"
-#include "wordid.h" // cdec
-
using namespace std;
namespace dtrain
@@ -111,51 +103,28 @@ make_ngram_counts(const vector<WordID>& hyp, const vector<WordID>& ref, const un
return counts;
}
-struct LocalScorer
-{
- unsigned N_;
- vector<score_t> w_;
-
- virtual score_t
- Score(ScoredHyp& hyp, vector<WordID>& ref_ids, unsigned id)=0;
-
- void
- Init(unsigned N, vector<score_t> weights)
- {
- assert(N > 0);
- N_ = N;
- if (weights.empty()) for (unsigned i = 0; i < N_; i++) w_.push_back(1./N_);
- else w_ = weights;
- }
-
- score_t
- brevity_penaly(const unsigned hyp_len, const unsigned ref_len)
- {
- if (hyp_len > ref_len) return 1;
- return exp(1 - (score_t)ref_len/hyp_len);
- }
-};
-
struct BleuScorer : public LocalScorer
{
score_t Bleu(NgramCounts& counts, const unsigned hyp_len, const unsigned ref_len);
- score_t Score(ScoredHyp& hyp, vector<WordID>& ref_ids, unsigned id);
+ score_t Score(vector<WordID>& hyp, vector<WordID>& ref_ids);
};
struct StupidBleuScorer : public LocalScorer
{
- score_t Score(ScoredHyp& hyp, vector<WordID>& ref_ids, unsigned id);
+ score_t Score(vector<WordID>& hyp, vector<WordID>& ref);
};
struct SmoothBleuScorer : public LocalScorer
{
- score_t Score(ScoredHyp& hyp, vector<WordID>& ref_ids, unsigned id);
+ score_t Score(vector<WordID>& hyp, vector<WordID>& ref);
};
// FIXME
/*struct ApproxBleuScorer : public LocalScorer
{
- NgramCounts glob_onebest_counts;
+ bool prepped;
+
+ NgramCounts* glob_onebest_counts;
unsigned glob_hyp_len, glob_ref_len;
void Prep(NgramCounts& counts, const unsigned hyp_len, const unsigned ref_len);
@@ -171,7 +140,6 @@ struct SmoothBleuScorer : public LocalScorer
};*/
-
} // namespace
#endif