diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-08-09 01:18:32 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-08-09 01:18:32 -0400 |
commit | 2a9c9a414abc074ec4ea8a5494e8dd50e1f94d70 (patch) | |
tree | f0bab000a53595e2de5b138accac10b90322c6fe /utils/tdict.h | |
parent | bc2992ba96cd7af83da8522bdeb6e5dd94a5a11b (diff) |
gamma-poisson word length model
Diffstat (limited to 'utils/tdict.h')
-rw-r--r-- | utils/tdict.h | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/utils/tdict.h b/utils/tdict.h index 393146fa..03afc2e6 100644 --- a/utils/tdict.h +++ b/utils/tdict.h @@ -3,10 +3,9 @@ #include <string> #include <vector> +#include <cassert> #include "wordid.h" -#include <assert.h> - -class Dict; +#include "dict.h" struct TD { static WordID end(); // next id to be assigned; [begin,end) give the non-reserved tokens seen so far @@ -15,10 +14,18 @@ struct TD { static std::string GetString(const std::vector<WordID>& str); static std::string GetString(WordID const* i,WordID const* e); static int AppendString(const WordID& w, int pos, int bufsize, char* buffer); - static unsigned int NumWords(); - static WordID Convert(const std::string& s); - static WordID Convert(char const* s); - static const char* Convert(WordID w); + static unsigned int NumWords() { + return dict_.max(); + } + static WordID Convert(const std::string& s) { + return dict_.Convert(s); + } + static WordID Convert(char const* s) { + return dict_.Convert(std::string(s)); + } + static const std::string& Convert(WordID w) { + return dict_.Convert(w); + } private: static Dict dict_; }; |