summaryrefslogtreecommitdiff
path: root/rst_parser/arc_factored.cc
diff options
context:
space:
mode:
authorChris Dyer <prguest11@taipan.cs>2012-04-16 19:39:36 +0100
committerChris Dyer <prguest11@taipan.cs>2012-04-16 19:39:36 +0100
commitf2fcf9e8aa0e5dee75fd08ee915488ec1a741975 (patch)
treeca902dff574a0952f081c91417d56312f5113ccf /rst_parser/arc_factored.cc
parentd5a2a9c3bf18c1e414f79a757c1662fe422e2f5c (diff)
feature extraction helper
Diffstat (limited to 'rst_parser/arc_factored.cc')
-rw-r--r--rst_parser/arc_factored.cc21
1 files changed, 21 insertions, 0 deletions
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<boost::shared_ptr<ArcFeatureFunction> >& ffs,
+ SparseVector<double>* features) const {
+ SparseVector<weight_t> 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<boost::shared_ptr<ArcFeatureFunction> >& ffs) {
for (int i = 0; i < ffs.size(); ++i) {