summaryrefslogtreecommitdiff
path: root/decoder/ff_source_path.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@Chriss-MacBook-Air.local>2013-03-14 23:38:41 -0400
committerChris Dyer <cdyer@Chriss-MacBook-Air.local>2013-03-14 23:38:41 -0400
commit68fbe21c181d6804ebce52058ebccd1a0d77444c (patch)
tree402d4d92ca51d6f6415d9f09bc2ce9efde72fddc /decoder/ff_source_path.h
parent9b252a03a40b17608cbc8c4a75ce37d748855574 (diff)
source path features
Diffstat (limited to 'decoder/ff_source_path.h')
-rw-r--r--decoder/ff_source_path.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/decoder/ff_source_path.h b/decoder/ff_source_path.h
new file mode 100644
index 00000000..03126412
--- /dev/null
+++ b/decoder/ff_source_path.h
@@ -0,0 +1,26 @@
+#ifndef _FF_SOURCE_PATH_H_
+#define _FF_SOURCE_PATH_H_
+
+#include <vector>
+#include <map>
+#include "ff.h"
+
+class SourcePathFeatures : public FeatureFunction {
+ public:
+ SourcePathFeatures(const std::string& param);
+ protected:
+ virtual void TraversalFeaturesImpl(const SentenceMetadata& smeta,
+ const HG::Edge& edge,
+ const std::vector<const void*>& ant_contexts,
+ SparseVector<double>* features,
+ SparseVector<double>* estimated_features,
+ void* context) const;
+
+ private:
+ void FireBigramFeature(WordID prev, WordID cur, SparseVector<double>* features) const;
+ void FireUnigramFeature(WordID cur, SparseVector<double>* features) const;
+ mutable std::map<WordID, std::map<WordID, int> > bigram_fids;
+ mutable std::map<WordID, int> unigram_fids;
+};
+
+#endif