From a2e4142d6a737bff040c3f2a583da6e8244db01a Mon Sep 17 00:00:00 2001 From: graehl Date: Mon, 19 Jul 2010 22:51:33 +0000 Subject: shared_ptr for scores. todo: intrusive. git-svn-id: https://ws10smt.googlecode.com/svn/trunk@327 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/sparse_vector.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'decoder/sparse_vector.h') diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h index f41bedf5..5e785210 100644 --- a/decoder/sparse_vector.h +++ b/decoder/sparse_vector.h @@ -1,5 +1,7 @@ #ifndef _SPARSE_VECTOR_H_ #define _SPARSE_VECTOR_H_ +/* hack: index 0 never gets printed because cdyer is creative and efficient. features which have no weight got feature dict id 0, see, and the models all clobered that value. nobody wants to see it. except that vlad is also creative and efficient and stored the oracle bleu there. */ + // this is a modified version of code originally written // by Phil Blunsom @@ -54,6 +56,12 @@ public: } + // warning: exploits the fact that 0 values are always removed from map. change this if you change that. + bool nonzero(int index) const { + return values_.find(index) != values_.end(); + } + + const T operator[](int index) const { typename MapType::const_iterator found = values_.find(index); if (found == values_.end()) -- cgit v1.2.3