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
commit5b8253e0e1f1393a509fb9975ba8c1347af758ed (patch)
tree1790470b1d07a0b4973ebce19192e896566ea60b /mteval/ns_ssk.cc
parent2389a5a8a43dda87c355579838559515b0428421 (diff)
parentb203f8c5dc8cff1b9c9c2073832b248fcad0765a (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];
+}
+