From 2a9c9a414abc074ec4ea8a5494e8dd50e1f94d70 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 9 Aug 2012 01:18:32 -0400 Subject: gamma-poisson word length model --- utils/tdict.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'utils/tdict.h') 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 #include +#include #include "wordid.h" -#include - -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& 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_; }; -- cgit v1.2.3