summaryrefslogtreecommitdiff
path: root/decoder/ff_rules.cc
diff options
context:
space:
mode:
authorChris Dyer <redpony@gmail.com>2014-01-13 04:44:53 -0800
committerChris Dyer <redpony@gmail.com>2014-01-13 04:44:53 -0800
commit0ddc951bc8990c1253e6a873848ed69321615e0a (patch)
treebedf7fae11a13b181e64f3dc3e5ab562b7bed74f /decoder/ff_rules.cc
parentc148f8429c66103a401ba4c3a029e349cd11aa8a (diff)
parentb60df3ce6c1a509f52fb19703963caefcfc9859b (diff)
Merge pull request #36 from pks/master
RuleWordAlignmentFeatures, minor dtrain changes
Diffstat (limited to 'decoder/ff_rules.cc')
-rw-r--r--decoder/ff_rules.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/decoder/ff_rules.cc b/decoder/ff_rules.cc
index 410e083c..7bccf084 100644
--- a/decoder/ff_rules.cc
+++ b/decoder/ff_rules.cc
@@ -12,6 +12,7 @@
#include "verbose.h"
#include "tdict.h"
#include "hg.h"
+#include "trule.h"
using namespace std;
@@ -68,6 +69,28 @@ void RuleIdentityFeatures::TraversalFeaturesImpl(const SentenceMetadata& smeta,
features->add_value(it->second, 1);
}
+RuleWordAlignmentFeatures::RuleWordAlignmentFeatures(const std::string& param) {
+}
+
+void RuleWordAlignmentFeatures::PrepareForInput(const SentenceMetadata& smeta) {
+}
+
+void RuleWordAlignmentFeatures::TraversalFeaturesImpl(const SentenceMetadata& smeta,
+ const Hypergraph::Edge& edge,
+ const vector<const void*>& ant_contexts,
+ SparseVector<double>* features,
+ SparseVector<double>* estimated_features,
+ void* context) const {
+ const TRule& rule = *edge.rule_;
+ ostringstream os;
+ vector<AlignmentPoint> als = rule.als();
+ std::vector<AlignmentPoint>::const_iterator xx = als.begin();
+ for (; xx != als.end(); ++xx) {
+ os << "WA:" << TD::Convert(rule.f_[xx->s_]) << ":" << TD::Convert(rule.e_[xx->t_]);
+ }
+ features->add_value(FD::Convert(Escape(os.str())), 1);
+}
+
RuleSourceBigramFeatures::RuleSourceBigramFeatures(const std::string& param) {
}