diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-22 05:12:27 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-06-22 05:12:27 +0000 |
commit | 0172721855098ca02b207231a654dffa5e4eb1c9 (patch) | |
tree | 8069c3a62e2d72bd64a2cdeee9724b2679c8a56b /decoder/tdict.h | |
parent | 37728b8be4d0b3df9da81fdda2198ff55b4b2d91 (diff) |
initial checkin
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@2 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/tdict.h')
-rw-r--r-- | decoder/tdict.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/decoder/tdict.h b/decoder/tdict.h new file mode 100644 index 00000000..31f66367 --- /dev/null +++ b/decoder/tdict.h @@ -0,0 +1,30 @@ +#ifndef _TDICT_H_ +#define _TDICT_H_ + +#include <string> +#include <vector> +#include "wordid.h" + +class Vocab; + +struct TD { + static Vocab* dict_; + static void ConvertSentence(const std::string& sent, std::vector<WordID>* ids); + static void GetWordIDs(const std::vector<std::string>& strings, std::vector<WordID>* ids); + static std::string GetString(const std::vector<WordID>& str); + static int AppendString(const WordID& w, int pos, int bufsize, char* buffer) { + const char* word = TD::Convert(w); + const char* const end_buf = buffer + bufsize; + char* dest = buffer + pos; + while(dest < end_buf && *word) { + *dest = *word; + ++dest; + ++word; + } + return (dest - buffer); + } + static WordID Convert(const std::string& s); + static const char* Convert(const WordID& w); +}; + +#endif |