summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-02-22 14:43:16 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2011-02-22 14:43:16 -0500
commited3e4fcfc849784b521fa9f021a26e368caff21a (patch)
treebb8e51d3065ae6c5449320e0f8496791c3db9592
parent1bc872e74d2fd104ed8f32b3e08966739e18411b (diff)
split features more
-rw-r--r--decoder/ff_spans.cc8
-rw-r--r--decoder/ff_spans.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/decoder/ff_spans.cc b/decoder/ff_spans.cc
index 06593727..6e92535a 100644
--- a/decoder/ff_spans.cc
+++ b/decoder/ff_spans.cc
@@ -54,7 +54,10 @@ void SpanFeatures::TraversalFeaturesImpl(const SentenceMetadata& smeta,
assert(edge.i_ < beg_span_ids_.size());
assert(edge.i_ >= 0);
features->set_value(beg_span_ids_[edge.i_], 1);
- features->set_value(span_feats_(edge.i_,edge.j_), 1);
+ if (edge.rule_->lhs_ == kS)
+ features->set_value(span_feats_(edge.i_,edge.j_).second, 1);
+ else
+ features->set_value(span_feats_(edge.i_,edge.j_).second, 1);
if (edge.Arity() == 2) {
const TRule& rule = *edge.rule_;
if (rule.f_[0] == kS && rule.f_[1] == kX) {
@@ -105,7 +108,8 @@ void SpanFeatures::PrepareForInput(const SentenceMetadata& smeta) {
word = MapIfNecessary(word);
ostringstream pf;
pf << "SS:" << TD::Convert(bword) << "_" << TD::Convert(word);
- span_feats_(i,j) = FD::Convert(pf.str());
+ span_feats_(i,j).first = FD::Convert(pf.str());
+ span_feats_(i,j).second = FD::Convert("S_" + pf.str());
}
}
}
diff --git a/decoder/ff_spans.h b/decoder/ff_spans.h
index 5e90b7e0..4bf5d7e7 100644
--- a/decoder/ff_spans.h
+++ b/decoder/ff_spans.h
@@ -22,7 +22,7 @@ class SpanFeatures : public FeatureFunction {
WordID MapIfNecessary(const WordID& w) const;
const int kS;
const int kX;
- Array2D<int> span_feats_;
+ Array2D<std::pair<int,int> > span_feats_; // first for X, second for S
std::vector<int> end_span_ids_;
std::vector<int> beg_span_ids_;
std::map<WordID, WordID> word2class_; // optional projection to coarser class