diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:37:10 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:37:10 +0000 |
commit | a53461650fbdcd3cfe7543d28af9647ac3e5e47e (patch) | |
tree | e812756c733b34f9c16894265204acfa9f9998a9 /utils/fdict.h | |
parent | 19b59489bb600f438ad96f04ec5d5c5b6616c9c2 (diff) |
major refactor, break bad circular deps
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@509 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/fdict.h')
-rw-r--r-- | utils/fdict.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/utils/fdict.h b/utils/fdict.h new file mode 100644 index 00000000..f9673023 --- /dev/null +++ b/utils/fdict.h @@ -0,0 +1,34 @@ +#ifndef _FDICT_H_ +#define _FDICT_H_ + +#include <string> +#include <vector> +#include "dict.h" + +struct FD { + // 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, frozen_); + } + static inline const std::string& Convert(const WordID& w) { + return dict_.Convert(w); + } + static std::string Convert(WordID const *i,WordID const* e); + static std::string Convert(std::vector<WordID> const& v); + + // Escape any string to a form that can be used as the name + // of a weight in a weights file + static std::string Escape(const std::string& s); + static Dict dict_; + private: + static bool frozen_; +}; + +#endif |