summaryrefslogtreecommitdiff
path: root/decoder/ff_ruleshape.h
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-28 20:40:28 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-28 20:40:28 +0000
commitf96bf4df7e4a34b42373723cbe38e6c7425e3239 (patch)
tree0b57bda1e4e72ce6e679cad996e0150372dd0b25 /decoder/ff_ruleshape.h
parent07e5fa39b4cf87f72e4e12604f26cc6c235d69d7 (diff)
rule shape features
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@46 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_ruleshape.h')
-rw-r--r--decoder/ff_ruleshape.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/decoder/ff_ruleshape.h b/decoder/ff_ruleshape.h
new file mode 100644
index 00000000..23c9827e
--- /dev/null
+++ b/decoder/ff_ruleshape.h
@@ -0,0 +1,31 @@
+#ifndef _FF_RULESHAPE_H_
+#define _FF_RULESHAPE_H_
+
+#include <vector>
+#include "ff.h"
+
+class RuleShapeFeatures : public FeatureFunction {
+ public:
+ RuleShapeFeatures(const std::string& param);
+ protected:
+ virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta,
+ const Hypergraph::Edge& edge,
+ const std::vector<const void*>& ant_contexts,
+ SparseVector<double>* features,
+ SparseVector<double>* estimated_features,
+ void* context) const;
+ private:
+ struct Node {
+ int fid_;
+ Node() : fid_(-1) {}
+ std::map<bool, Node> next_;
+ };
+ Node fidtree_;
+ static const Node* Advance(const Node* cur, bool val) {
+ std::map<bool, Node>::const_iterator it = cur->next_.find(val);
+ if (it == cur->next_.end()) return NULL;
+ return &it->second;
+ }
+};
+
+#endif