diff options
author | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2013-03-15 00:17:55 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2013-03-15 00:17:55 -0400 |
commit | 9f1d72fa4dc231eb8cdb737becfc10452b5daef4 (patch) | |
tree | 8fb1b5b107eb57967f8af12456194d4c7a70c77c /decoder | |
parent | 5a338d692aba7b8dcd682b96ed3f3e600187c176 (diff) |
fix bug
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/ff_source_path.cc | 8 |
1 files changed, 5 insertions, 3 deletions
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<double>* features) const { int& fid = bigram_fids[prev][cur]; @@ -27,10 +27,11 @@ void SourcePathFeatures::TraversalFeaturesImpl(const SentenceMetadata& smeta, WordID* res = reinterpret_cast<WordID*>(context); const vector<int>& 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<const WordID*>(ant_contexts[-cur]); + if (cur < 0) + cur = *reinterpret_cast<const WordID*>(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; } + |