summaryrefslogtreecommitdiff
path: root/mteval/ns_ssk.cc
diff options
context:
space:
mode:
authorAvneesh Saluja <asaluja@gmail.com>2013-03-28 18:28:16 -0700
committerAvneesh Saluja <asaluja@gmail.com>2013-03-28 18:28:16 -0700
commit3d8d656fa7911524e0e6885647173474524e0784 (patch)
tree81b1ee2fcb67980376d03f0aa48e42e53abff222 /mteval/ns_ssk.cc
parentbe7f57fdd484e063775d7abf083b9fa4c403b610 (diff)
parent96fedabebafe7a38a6d5928be8fff767e411d705 (diff)
fixed conflicts
Diffstat (limited to 'mteval/ns_ssk.cc')
-rw-r--r--mteval/ns_ssk.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/mteval/ns_ssk.cc b/mteval/ns_ssk.cc
new file mode 100644
index 00000000..c94e62ca
--- /dev/null
+++ b/mteval/ns_ssk.cc
@@ -0,0 +1,32 @@
+#include "ns_ssk.h"
+
+#include <vector>
+
+#include "kernel_string_subseq.h"
+#include "tdict.h"
+
+static const unsigned kNUMFIELDS = 2;
+static const unsigned kSIMILARITY = 0;
+static const unsigned kCOUNT = 1;
+
+unsigned SSKMetric::SufficientStatisticsVectorSize() const {
+ return kNUMFIELDS;
+}
+
+void SSKMetric::ComputeSufficientStatistics(const std::vector<WordID>& hyp,
+ const std::vector<std::vector<WordID> >& refs,
+ SufficientStats* out) const {
+ out->fields.resize(kNUMFIELDS);
+ out->fields[kCOUNT] = 1;
+ float bestsim = 0;
+ for (unsigned i = 0; i < refs.size(); ++i) {
+ float s = ssk<4>(hyp, refs[i], 0.8);
+ if (s > bestsim) bestsim = s;
+ }
+ out->fields[kSIMILARITY] = bestsim;
+}
+
+float SSKMetric::ComputeScore(const SufficientStats& stats) const {
+ return stats.fields[kSIMILARITY] / stats.fields[kCOUNT];
+}
+