From cba324bee086f4dd0fc9df204d33ff7eb9b6c323 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Fri, 15 Mar 2013 00:17:55 -0400 Subject: fix bug --- decoder/ff_source_path.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'decoder') diff --git a/decoder/ff_source_path.cc b/decoder/ff_source_path.cc index 56cbfc48..2a3bee2e 100644 --- a/decoder/ff_source_path.cc +++ b/decoder/ff_source_path.cc @@ -4,7 +4,7 @@ using namespace std; -SourcePathFeatures::SourcePathFeatures(const string& param) : FeatureFunction(4) {} +SourcePathFeatures::SourcePathFeatures(const string& param) : FeatureFunction(sizeof(int)) {} void SourcePathFeatures::FireBigramFeature(WordID prev, WordID cur, SparseVector* features) const { int& fid = bigram_fids[prev][cur]; @@ -27,10 +27,11 @@ void SourcePathFeatures::TraversalFeaturesImpl(const SentenceMetadata& smeta, WordID* res = reinterpret_cast(context); const vector& f = edge.rule_->f(); int prev = 0; + unsigned ntc = 0; for (unsigned i = 0; i < f.size(); ++i) { int cur = f[i]; - if (cur <= 0) - cur = *reinterpret_cast(ant_contexts[-cur]); + if (cur < 0) + cur = *reinterpret_cast(ant_contexts[ntc++]); else FireUnigramFeature(cur, features); if (prev) FireBigramFeature(prev, cur, features); @@ -38,3 +39,4 @@ void SourcePathFeatures::TraversalFeaturesImpl(const SentenceMetadata& smeta, } *res = prev; } + -- cgit v1.2.3