diff options
author | Chris Dyer <redpony@gmail.com> | 2009-12-14 20:35:11 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2009-12-14 20:35:11 -0500 |
commit | 851e389dffdd6996ea32d70defb8906de80b9edc (patch) | |
tree | 8c68ee77205badc056b8ab5b332e67e3e98017df /src/tdict.cc | |
parent | dc6930c00b4b276883280cff1ed6dcd9ddef03c7 (diff) |
few small fixes of alignment tools, add new orthographic similarity feature for word aligner, final naming of directories, libraries in cdec
Diffstat (limited to 'src/tdict.cc')
-rw-r--r-- | src/tdict.cc | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/tdict.cc b/src/tdict.cc deleted file mode 100644 index c00d20b8..00000000 --- a/src/tdict.cc +++ /dev/null @@ -1,49 +0,0 @@ -#include "Ngram.h" -#include "dict.h" -#include "tdict.h" -#include "Vocab.h" - -using namespace std; - -Vocab* TD::dict_ = new Vocab; - -static const string empty; -static const string space = " "; - -WordID TD::Convert(const std::string& s) { - return dict_->addWord((VocabString)s.c_str()); -} - -const char* TD::Convert(const WordID& w) { - return dict_->getWord((VocabIndex)w); -} - -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) - ids->push_back(TD::Convert(*i)); -} - -std::string TD::GetString(const std::vector<WordID>& str) { - string res; - for (vector<WordID>::const_iterator i = str.begin(); i != str.end(); ++i) - res += (i == str.begin() ? empty : space) + TD::Convert(*i); - return res; -} - -void TD::ConvertSentence(const std::string& sent, std::vector<WordID>* ids) { - string s = sent; - int last = 0; - ids->clear(); - for (int i=0; i < s.size(); ++i) - if (s[i] == 32 || s[i] == '\t') { - s[i]=0; - if (last != i) { - ids->push_back(Convert(&s[last])); - } - last = i + 1; - } - if (last != s.size()) - ids->push_back(Convert(&s[last])); -} - |