summaryrefslogtreecommitdiff
path: root/decoder/node_state_hash.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-04-09 20:20:13 -0400
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-04-09 20:20:13 -0400
commit6f6c219c5fe032869d8f2235726fb3b9b38c4354 (patch)
treead77d662db1af40c5e0d95ec5d64a1c9326ff485 /decoder/node_state_hash.h
parent74401769fdb8b16f44df8911070b7ae091de5fef (diff)
parent5f3ec63bf30459d97ad9e61d4e9b3b734a4867bf (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'decoder/node_state_hash.h')
-rw-r--r--decoder/node_state_hash.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/decoder/node_state_hash.h b/decoder/node_state_hash.h
index cdc05877..9fc01a09 100644
--- a/decoder/node_state_hash.h
+++ b/decoder/node_state_hash.h
@@ -3,14 +3,19 @@
#include <cassert>
#include <cstring>
+#include "tdict.h"
#include "murmur_hash3.h"
#include "ffset.h"
namespace cdec {
struct FirstPassNode {
- FirstPassNode(int cat, int i, int j, int pi, int pj) : lhs(cat), s(i), t(j), u(pi), v(pj) {}
- int32_t lhs;
+ FirstPassNode(int cat, int i, int j, int pi, int pj) : s(i), t(j), u(pi), v(pj) {
+ memset(lhs, 0, 120);
+ unsigned it = 0;
+ for (auto& c : TD::Convert(-cat)) { lhs[it++] = c; if (it == 120) break; }
+ }
+ char lhs[120];
short s;
short t;
short u;
@@ -23,6 +28,7 @@ namespace cdec {
}
inline uint64_t HashNode(uint64_t old_hash, const FFState& state) {
+ if (state.size() == 0) return old_hash;
uint8_t buf[1024];
std::memcpy(buf, &old_hash, sizeof(uint64_t));
assert(state.size() < (1024u - sizeof(uint64_t)));