summaryrefslogtreecommitdiff
path: root/utils/tdict.cc
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-08-09 01:18:32 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-08-09 01:18:32 -0400
commit2a9c9a414abc074ec4ea8a5494e8dd50e1f94d70 (patch)
treef0bab000a53595e2de5b138accac10b90322c6fe /utils/tdict.cc
parentbc2992ba96cd7af83da8522bdeb6e5dd94a5a11b (diff)
gamma-poisson word length model
Diffstat (limited to 'utils/tdict.cc')
-rw-r--r--utils/tdict.cc19
1 files changed, 2 insertions, 17 deletions
diff --git a/utils/tdict.cc b/utils/tdict.cc
index f33bd576..fd2b76cb 100644
--- a/utils/tdict.cc
+++ b/utils/tdict.cc
@@ -13,22 +13,6 @@ using namespace std;
Dict TD::dict_;
-unsigned int TD::NumWords() {
- return dict_.max();
-}
-
-WordID TD::Convert(const std::string& s) {
- return dict_.Convert(s);
-}
-
-WordID TD::Convert(char const* s) {
- return dict_.Convert(string(s));
-}
-
-const char* TD::Convert(WordID w) {
- return dict_.Convert(w).c_str();
-}
-
void TD::GetWordIDs(const std::vector<std::string>& strings, std::vector<WordID>* ids) {
ids->clear();
for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i)
@@ -57,7 +41,8 @@ std::string TD::GetString(WordID const* i,WordID const* e) {
int TD::AppendString(const WordID& w, int pos, int bufsize, char* buffer)
{
- const char* word = TD::Convert(w);
+ const string& s = TD::Convert(w);
+ const char* word = s.c_str();
const char* const end_buf = buffer + bufsize;
char* dest = buffer + pos;
while(dest < end_buf && *word) {