From b0d1a4f0c9718412691f279b9092f18073cf5094 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 16 Apr 2012 19:39:36 +0100 Subject: feature extraction helper --- rst_parser/arc_factored.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'rst_parser/arc_factored.cc') diff --git a/rst_parser/arc_factored.cc b/rst_parser/arc_factored.cc index 44e769b8..34c689f4 100644 --- a/rst_parser/arc_factored.cc +++ b/rst_parser/arc_factored.cc @@ -12,6 +12,27 @@ using namespace std; using namespace std::tr1; using namespace boost; +void EdgeSubset::ExtractFeatures(const TaggedSentence& sentence, + const std::vector >& ffs, + SparseVector* features) const { + SparseVector efmap; + for (int i = 0; i < ffs.size(); ++i) { + const ArcFeatureFunction& ff= *ffs[i]; + for (int j = 0; j < h_m_pairs.size(); ++j) { + efmap.clear(); + ff.EgdeFeatures(sentence, h_m_pairs[j].first, + h_m_pairs[j].second, + &efmap); + (*features) += efmap; + } + for (int j = 0; j < roots.size(); ++j) { + efmap.clear(); + ff.EgdeFeatures(sentence, -1, roots[j], &efmap); + (*features) += efmap; + } + } +} + void ArcFactoredForest::ExtractFeatures(const TaggedSentence& sentence, const std::vector >& ffs) { for (int i = 0; i < ffs.size(); ++i) { -- cgit v1.2.3