summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'decoder')
-rw-r--r--decoder/ff_wordalign.cc11
-rw-r--r--decoder/ff_wordalign.h2
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,