summaryrefslogtreecommitdiff
path: root/rst_parser/arc_factored.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-04-16 22:42:24 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-04-16 22:42:24 -0400
commit23dcec445852d140291bba4a8c40bb0e47e9a266 (patch)
tree9606eb3d4e3d055e1086f6988c6f80cc1b34121f /rst_parser/arc_factored.cc
parent964b58ae8302e0fadcceb982c92d49ab25538cd5 (diff)
refactor some code, simplify, fix typos
Diffstat (limited to 'rst_parser/arc_factored.cc')
-rw-r--r--rst_parser/arc_factored.cc40
1 files changed, 17 insertions, 23 deletions
diff --git a/rst_parser/arc_factored.cc b/rst_parser/arc_factored.cc
index 34c689f4..74bf7516 100644
--- a/rst_parser/arc_factored.cc
+++ b/rst_parser/arc_factored.cc
@@ -13,36 +13,30 @@ using namespace std::tr1;
using namespace boost;
void EdgeSubset::ExtractFeatures(const TaggedSentence& sentence,
- const std::vector<boost::shared_ptr<ArcFeatureFunction> >& ffs,
+ const ArcFeatureFunctions& 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;
- }
+ for (int j = 0; j < h_m_pairs.size(); ++j) {
+ efmap.clear();
+ ffs.EdgeFeatures(sentence, h_m_pairs[j].first,
+ h_m_pairs[j].second,
+ &efmap);
+ (*features) += efmap;
+ }
+ for (int j = 0; j < roots.size(); ++j) {
+ efmap.clear();
+ ffs.EdgeFeatures(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) {
- const ArcFeatureFunction& ff = *ffs[i];
- for (int m = 0; m < num_words_; ++m) {
- for (int h = 0; h < num_words_; ++h) {
- ff.EgdeFeatures(sentence, h, m, &edges_(h,m).features);
- }
- ff.EgdeFeatures(sentence, -1, m, &root_edges_[m].features);
+ const ArcFeatureFunctions& ffs) {
+ for (int m = 0; m < num_words_; ++m) {
+ for (int h = 0; h < num_words_; ++h) {
+ ffs.EdgeFeatures(sentence, h, m, &edges_(h,m).features);
}
+ ffs.EdgeFeatures(sentence, -1, m, &root_edges_[m].features);
}
}