diff options
author | Chris Dyer <redpony@gmail.com> | 2009-12-18 01:27:19 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2009-12-18 01:27:19 -0500 |
commit | 1aac806af7785ab440d300ca5cfa8833e3ed61d3 (patch) | |
tree | 4a2ffa484af029ebc542f2cdf7bb6da93325b29a /decoder/trule.cc | |
parent | 40ac2d31391c27b168b0294e7683cb69da29f868 (diff) |
add support for freezing the feature set to a user-specified list, even if feature detectors create additional features
Diffstat (limited to 'decoder/trule.cc')
-rw-r--r-- | decoder/trule.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/decoder/trule.cc b/decoder/trule.cc index b8f6995e..505839c7 100644 --- a/decoder/trule.cc +++ b/decoder/trule.cc @@ -126,7 +126,11 @@ bool TRule::ReadFromString(const string& line, bool strict, bool mono) { if (fv > 9) { cerr << "Too many phrasetable scores - used named format\n"; abort(); } fname[12]='0' + fv; ++fv; - scores_.set_value(FD::Convert(fname), atof(&ss[start])); + // if the feature set is frozen, this may return zero, indicating an + // undefined feature + const int fid = FD::Convert(fname); + if (fid) + scores_.set_value(fid, atof(&ss[start])); //cerr << "F: " << fname << " VAL=" << scores_.value(FD::Convert(fname)) << endl; } else { const int fid = FD::Convert(ss.substr(start, end - start)); @@ -136,7 +140,8 @@ bool TRule::ReadFromString(const string& line, bool strict, bool mono) { ++end; if (end < len) { ss[end] = 0; } assert(start < len); - scores_.set_value(fid, atof(&ss[start])); + if (fid) + scores_.set_value(fid, atof(&ss[start])); //cerr << "F: " << FD::Convert(fid) << " VAL=" << scores_.value(fid) << endl; } start = end + 1; |