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/sparse_vector.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'decoder/sparse_vector.h') diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h index 6a8c9bf4..2b4a63a9 100644 --- a/decoder/sparse_vector.h +++ b/decoder/sparse_vector.h @@ -185,10 +185,15 @@ public: } std::ostream &operator<<(std::ostream &out) const { + bool first = true; for (typename std::map::const_iterator - it = _values.begin(); it != _values.end(); ++it) - out << (it == _values.begin() ? "" : ";") - << FD::Convert(it->first) << '=' << it->second; + it = _values.begin(); it != _values.end(); ++it) { + // by definition feature id 0 is a dummy value + if (it->first == 0) continue; + out << (first ? "" : ";") + << FD::Convert(it->first) << '=' << it->second; + first = false; + } return out; } @@ -216,6 +221,9 @@ public: void clear() { _values.clear(); } + void clear_value(int index) { + _values.erase(index); + } void swap(SparseVector& other) { _values.swap(other._values); -- cgit v1.2.3