summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2013-03-15 00:17:55 -0400
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2013-03-15 00:17:55 -0400
commitcba324bee086f4dd0fc9df204d33ff7eb9b6c323 (patch)
treef8fe36694370a7d07bf1d336e1f0c874e9202a16
parent37162522a07551b261c445a92245445c5458f759 (diff)
fix bug
-rw-r--r--decoder/ff_source_path.cc8
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;
}
+