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/fdict.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'decoder/fdict.h') diff --git a/decoder/fdict.h b/decoder/fdict.h index ff491cfb..d05f1706 100644 --- a/decoder/fdict.h +++ b/decoder/fdict.h @@ -6,16 +6,23 @@ #include "dict.h" struct FD { - static Dict dict_; + // once the FD is frozen, new features not already in the + // dictionary will return 0 + static void Freeze() { + frozen_ = true; + } static inline int NumFeats() { return dict_.max() + 1; } static inline WordID Convert(const std::string& s) { - return dict_.Convert(s); + return dict_.Convert(s, frozen_); } static inline const std::string& Convert(const WordID& w) { return dict_.Convert(w); } + static Dict dict_; + private: + static bool frozen_; }; #endif -- cgit v1.2.3