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/fdict.h | |
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/fdict.h')
-rw-r--r-- | decoder/fdict.h | 11 |
1 files changed, 9 insertions, 2 deletions
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 |