diff options
author | Chris Dyer <redpony@gmail.com> | 2009-12-19 15:08:02 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2009-12-19 15:08:02 -0500 |
commit | 9be811a26da86b87bac8696f155188d9a675e61b (patch) | |
tree | 5c9e327fad80d666fe019623ab3fab8e34d6db04 /decoder | |
parent | 27db9d8c05188f64c17d61c394d3dafe8b8e93d8 (diff) |
few fixes
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/ff_wordalign.cc | 11 | ||||
-rw-r--r-- | 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<double>* features) const { + WordID left = *static_cast<const WordID*>(context); + int left_wc = *(static_cast<const int*>(context) + 1); + if (left_wc == 1) + FireFeature(-1, left, features); + FireFeature(left, -1, features); +} + void SourcePOSBigram::FireFeature(WordID left, WordID right, SparseVector<double>* 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<WordID, Class2FID> Class2Class2FID; class SourcePOSBigram : public FeatureFunction { public: SourcePOSBigram(const std::string& param); + virtual void FinalTraversalFeatures(const void* context, + SparseVector<double>* features) const; protected: virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta, const Hypergraph::Edge& edge, |