From 9be811a26da86b87bac8696f155188d9a675e61b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sat, 19 Dec 2009 15:08:02 -0500 Subject: few fixes --- decoder/ff_wordalign.cc | 11 +++++++++-- decoder/ff_wordalign.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/decoder/ff_wordalign.cc b/decoder/ff_wordalign.cc index f07eda02..c9f90541 100644 --- a/decoder/ff_wordalign.cc +++ b/decoder/ff_wordalign.cc @@ -144,6 +144,15 @@ SourcePOSBigram::SourcePOSBigram(const std::string& param) : cerr << " (" << pos_.size() << " lines)\n"; } +void SourcePOSBigram::FinalTraversalFeatures(const void* context, + SparseVector* features) const { + WordID left = *static_cast(context); + int left_wc = *(static_cast(context) + 1); + if (left_wc == 1) + FireFeature(-1, left, features); + FireFeature(left, -1, features); +} + void SourcePOSBigram::FireFeature(WordID left, WordID right, SparseVector* features) const { @@ -187,8 +196,6 @@ void SourcePOSBigram::TraversalFeaturesImpl(const SentenceMetadata& smeta, FireFeature(-1, left, features); FireFeature(left, right, features); out_word_count = left_wc + right_wc; - if (out_word_count == smeta.GetSourceLength()) - FireFeature(right, -1, features); out_context = right; } } diff --git a/decoder/ff_wordalign.h b/decoder/ff_wordalign.h index 554dd23e..aea4c950 100644 --- a/decoder/ff_wordalign.h +++ b/decoder/ff_wordalign.h @@ -43,6 +43,8 @@ typedef std::map Class2Class2FID; class SourcePOSBigram : public FeatureFunction { public: SourcePOSBigram(const std::string& param); + virtual void FinalTraversalFeatures(const void* context, + SparseVector* features) const; protected: virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta, const Hypergraph::Edge& edge, -- cgit v1.2.3