From 1aac806af7785ab440d300ca5cfa8833e3ed61d3 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Fri, 18 Dec 2009 01:27:19 -0500 Subject: add support for freezing the feature set to a user-specified list, even if feature detectors create additional features --- decoder/trule.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'decoder/trule.cc') 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; -- cgit v1.2.3