summaryrefslogtreecommitdiff
path: root/decoder/dict.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-20 19:43:31 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-20 19:43:31 +0000
commit2621d66cc3de03395ab0c7a6f85113ed45189641 (patch)
tree95d57d0f88fc7e5c9fdbd9c3f2a1117dda1aa4ae /decoder/dict.h
parentd0063ea4ae7dbad8a9148ca3ebf6855cd2aa9af6 (diff)
optional google dense_hash_map, srim vocab (TDICT) as static - may help valgrind warning?
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@339 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/dict.h')
-rw-r--r--decoder/dict.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/decoder/dict.h b/decoder/dict.h
index 38231db6..82e8c0c0 100644
--- a/decoder/dict.h
+++ b/decoder/dict.h
@@ -3,7 +3,11 @@
#include <cassert>
#include <cstring>
-#include <tr1/unordered_map>
+#ifdef HAVE_SPARSEHASH
+# include <google/dense_hash_map>
+#else
+# include <tr1/unordered_map>
+#endif
#include <string>
#include <vector>
@@ -12,10 +16,22 @@
#include "wordid.h"
class Dict {
- typedef std::tr1::unordered_map<std::string, WordID, boost::hash<std::string> > Map;
+ typedef
+#ifdef HAVE_SPARSEHASH
+ std::tr1::unordered_map
+#else
+ google::dense_hash_map
+#endif
+ <std::string, WordID, boost::hash<std::string> > Map;
public:
- Dict() : b0_("<bad0>") { words_.reserve(1000); }
+ Dict() : b0_("<bad0>") {
+#ifdef HAVE_SPARSEHASH
+ d_.set_empty_key("<bad1>");
+ d_.set_deleted_key("<bad2>");
+#endif
+ words_.reserve(1000);
+ }
inline int max() const { return words_.size(); }
@@ -32,7 +48,7 @@ class Dict {
}
}
- inline WordID Convert(const std::vector<std::string>& words, bool frozen = false)
+ inline WordID Convert(const std::vector<std::string>& words, bool frozen = false)
{ return Convert(toString(words), frozen); }
static inline std::string toString(const std::vector<std::string>& words) {