diff options
author | Chris Dyer <cdyer@Chriss-MacBook-Air.local> | 2013-02-16 03:18:42 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@Chriss-MacBook-Air.local> | 2013-02-16 03:18:42 -0500 |
commit | d9f77a14d4e217dc8984871802bbccc66a2c9864 (patch) | |
tree | ffb1259b8dd2e8d89847a07ce3e87199133154b8 /mteval/ns_ssk.cc | |
parent | f5708c7e6efc5dc249b1d2421a636c087231f275 (diff) |
new metric
Diffstat (limited to 'mteval/ns_ssk.cc')
-rw-r--r-- | mteval/ns_ssk.cc | 32 |
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]; +} + |