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
commitad4ed0105624590daf540d8f0c77d1c0cf28e9fd (patch)
tree7573e453f151dccd60e5387b4a92cce8db3fde1e
parent4324cdb03ec1f8332ad053e9f4f85170027b3938 (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