diff options
author | Chris Dyer <redpony@gmail.com> | 2014-01-15 20:33:07 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-01-15 20:33:07 -0500 |
commit | f3f8dbaec0c91d90fc2e9fdec988081659a7c48c (patch) | |
tree | 37984cba680c1dbaf516968920b81533df0d8820 /decoder/ff_rules.cc | |
parent | fde257636aa3a2fa04f89829176a345e15664565 (diff) | |
parent | 7a9c1c85fecb787b1ee4b8e9552ed35a635e3c39 (diff) |
Merge branch 'master' of https://github.com/redpony/cdec
Diffstat (limited to 'decoder/ff_rules.cc')
-rw-r--r-- | decoder/ff_rules.cc | 23 |
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) { } |