From 774702f245045ae3752e67b85906a7df4b333cf5 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sat, 16 Feb 2013 03:18:42 -0500 Subject: new metric --- mteval/ns_ssk.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mteval/ns_ssk.cc (limited to 'mteval/ns_ssk.cc') 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 + +#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& hyp, + const std::vector >& 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]; +} + -- cgit v1.2.3