summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-09-17 22:38:42 +0100
committerChris Dyer <cdyer@cs.cmu.edu>2011-09-17 22:38:42 +0100
commit538361fb1ea261ba49d3cec7d88352473ab49eab (patch)
tree7bd2b2c231b7cce8e9b30735e385d2a954e5862b
parent06e3c6c886cafc967688928ad62f380f0fcefe9e (diff)
arity > 0 rules only for sss features
-rw-r--r--decoder/ff_source_syntax.cc32
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);
}