#ifndef _FF_SPANS_H_ #define _FF_SPANS_H_ #include #include #include "ff.h" #include "array2d.h" #include "wordid.h" class SpanFeatures : public FeatureFunction { public: SpanFeatures(const std::string& param); protected: virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta, const Hypergraph::Edge& edge, const std::vector& ant_contexts, SparseVector* features, SparseVector* estimated_features, void* context) const; virtual void PrepareForInput(const SentenceMetadata& smeta); private: WordID MapIfNecessary(const WordID& w) const; const int kS; const int kX; Array2D > span_feats_; // first for X, second for S std::vector end_span_ids_; std::vector beg_span_ids_; std::map word2class_; // optional projection to coarser class // collapsed feature values bool use_collapsed_features_; int fid_beg_; int fid_end_; int fid_span_s_; int fid_span_; std::map feat2val_; std::vector end_span_vals_; std::vector beg_span_vals_; Array2D > span_vals_; WordID oov_; }; #endif