summaryrefslogtreecommitdiff
path: root/mteval
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-01-27 02:31:00 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2012-01-27 02:31:00 -0500
commit481a120564fdb73c8c6833e2102acb533683261c (patch)
treec4b39308283f8f5b64ac13691b1d29de31cc15ce /mteval
parent4c2360119def2fb624d2691b355b1908c511f004 (diff)
migrate mert to the new scorer interface
Diffstat (limited to 'mteval')
-rw-r--r--mteval/ns.cc4
-rw-r--r--mteval/ns.h10
2 files changed, 12 insertions, 2 deletions
diff --git a/mteval/ns.cc b/mteval/ns.cc
index 68c8deaa..da678b84 100644
--- a/mteval/ns.cc
+++ b/mteval/ns.cc
@@ -136,6 +136,10 @@ struct BleuSegmentEvaluator : public SegmentEvaluator {
float* correct, // N elements reserved
float* hyp, // N elements reserved
bool clip_counts = true) const {
+ // clear clipping stats
+ for (typename NGramCountMap::iterator it = ngrams_.begin(); it != ngrams_.end(); ++it)
+ it->second.second = 0;
+
vector<WordID> ngram(N);
*correct *= 0;
*hyp *= 0;
diff --git a/mteval/ns.h b/mteval/ns.h
index 622265db..d88c263b 100644
--- a/mteval/ns.h
+++ b/mteval/ns.h
@@ -6,6 +6,7 @@
#include <map>
#include <boost/shared_ptr.hpp>
#include "wordid.h"
+#include <iostream>
class SufficientStats {
public:
@@ -43,6 +44,11 @@ class SufficientStats {
bool operator==(const SufficientStats& other) const {
return other.fields == fields;
}
+ bool IsAdditiveIdentity() const {
+ for (unsigned i = 0; i < fields.size(); ++i)
+ if (fields[i]) return false;
+ return true;
+ }
size_t size() const { return fields.size(); }
float operator[](size_t i) const {
if (i < fields.size()) return fields[i];
@@ -54,12 +60,12 @@ class SufficientStats {
std::vector<float> fields;
};
-inline const SufficientStats& operator+(const SufficientStats& a, const SufficientStats& b) {
+inline const SufficientStats operator+(const SufficientStats& a, const SufficientStats& b) {
SufficientStats res(a);
return res += b;
}
-inline const SufficientStats& operator-(const SufficientStats& a, const SufficientStats& b) {
+inline const SufficientStats operator-(const SufficientStats& a, const SufficientStats& b) {
SufficientStats res(a);
return res -= b;
}