diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-09-17 22:38:42 +0100 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-09-17 22:38:42 +0100 |
commit | 5d7ac6050aab3eac5121a2168fe9bd81453d118a (patch) | |
tree | 2c0b8f013038c501c5938fff856ce87b894b801f /decoder | |
parent | e7d2352ed630d16a790113223cd8a80155f61615 (diff) |
arity > 0 rules only for sss features
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/ff_source_syntax.cc | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/decoder/ff_source_syntax.cc b/decoder/ff_source_syntax.cc index 2df31c3a..fc341bb0 100644 --- a/decoder/ff_source_syntax.cc +++ b/decoder/ff_source_syntax.cc @@ -166,24 +166,26 @@ struct SourceSpanSizeFeaturesImpl { } int FireFeatures(const TRule& rule, const int i, const int j, const WordID* ants, SparseVector<double>* feats) { - int& fid = fids(i,j)[&rule]; - if (fid <= 0) { - ostringstream os; - os << "SSS:"; - unsigned ntc = 0; - for (unsigned k = 0; k < rule.f_.size(); ++k) { - if (k > 0) os << '_'; - int fj = rule.f_[k]; - if (fj <= 0) { - os << '[' << TD::Convert(-fj) << ants[ntc++] << ']'; - } else { - os << TD::Convert(fj); + if (rule.Arity() > 0) { + int& fid = fids(i,j)[&rule]; + if (fid <= 0) { + ostringstream os; + os << "SSS:"; + unsigned ntc = 0; + for (unsigned k = 0; k < rule.f_.size(); ++k) { + if (k > 0) os << '_'; + int fj = rule.f_[k]; + if (fj <= 0) { + os << '[' << TD::Convert(-fj) << ants[ntc++] << ']'; + } else { + os << TD::Convert(fj); + } } + fid = FD::Convert(os.str()); } - fid = FD::Convert(os.str()); + if (fid > 0) + feats->set_value(fid, 1.0); } - if (fid > 0) - feats->set_value(fid, 1.0); return SpanSizeTransform(j - i); } |