diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:37:10 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:37:10 +0000 |
commit | a53461650fbdcd3cfe7543d28af9647ac3e5e47e (patch) | |
tree | e812756c733b34f9c16894265204acfa9f9998a9 /utils/dict.cc | |
parent | 19b59489bb600f438ad96f04ec5d5c5b6616c9c2 (diff) |
major refactor, break bad circular deps
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@509 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/dict.cc')
-rw-r--r-- | utils/dict.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/utils/dict.cc b/utils/dict.cc new file mode 100644 index 00000000..2d6986c8 --- /dev/null +++ b/utils/dict.cc @@ -0,0 +1,27 @@ +#include "dict.h" + +#include <string> +#include <vector> + +void TokenizeStringSeparator( + const std::string& str, + const std::string& separator, + std::vector<std::string>* tokens) { + + size_t pos = 0; + std::string::size_type nextPos = str.find(separator, pos); + + while (nextPos != std::string::npos) { + tokens->push_back(str.substr(pos, nextPos - pos)); + pos = nextPos + separator.size(); + nextPos = str.find(separator, pos); + } + tokens->push_back(str.substr(pos, nextPos - pos)); +} + + +void Dict::AsVector(const WordID& id, std::vector<std::string>* results) const { + results->clear(); + TokenizeStringSeparator(Convert(id), " ||| ", results); +} + |