summaryrefslogtreecommitdiff
path: root/decoder/ff_ruleshape.h
blob: 23c9827e39f1c91ae8c63a3c17c9084de20acdda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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