#ifndef _TDICT_H_ #define _TDICT_H_ #include #include #include "wordid.h" #include class Vocab; struct TD { /* // disabled for now static const int reserved_begin=10; // allow room for SRI special tokens e.g. unk ss se pause. tokens until this get "" static const int n_reserved=10; // 0...n_reserved-1 get token '' static inline WordID reserved(int i) { assert(i>=0 && i"; static char const* const se_str; //=""; static char const* const unk_str; //=""; static WordID ss,se,unk; // x=Convert(x_str) static WordID end(); // next id to be assigned; [begin,end) give the non-reserved tokens seen so far static Vocab dict_; static void ConvertSentence(std::string const& sent, std::vector* ids); static void GetWordIDs(const std::vector& strings, std::vector* ids); static std::string GetString(const std::vector& str); 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(const WordID& w); }; struct ToTD { typedef WordID result_type; result_type operator()(std::string const& t) const { return TD::Convert(t); } }; #endif