summaryrefslogtreecommitdiff
path: root/mteval/ns.h
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
commit3c1c98b5aec7aec34432ddc37385df06d301bdd5 (patch)
treeb1fcf24c73441cb7233977c31bc50d5f82c88f21 /mteval/ns.h
parentf960ab86f4b44bf515af4bf43aa27147a0e7875a (diff)
migrate mert to the new scorer interface
Diffstat (limited to 'mteval/ns.h')
-rw-r--r--mteval/ns.h10
1 files changed, 8 insertions, 2 deletions
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;
}