From ad4ed0105624590daf540d8f0c77d1c0cf28e9fd Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 22 Feb 2011 14:43:16 -0500 Subject: split features more --- decoder/ff_spans.cc | 8 ++++++-- decoder/ff_spans.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'decoder') 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 span_feats_; + Array2D > span_feats_; // first for X, second for S std::vector end_span_ids_; std::vector beg_span_ids_; std::map word2class_; // optional projection to coarser class -- cgit v1.2.3