From 80686d4e567bae579ea39e009826a2de92cd4ace Mon Sep 17 00:00:00 2001 From: redpony Date: Wed, 11 Aug 2010 02:37:10 +0000 Subject: major refactor, break bad circular deps git-svn-id: https://ws10smt.googlecode.com/svn/trunk@509 ec762483-ff6d-05da-a07a-a48fb63a330f --- utils/dict.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 utils/dict.cc (limited to 'utils/dict.cc') 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 +#include + +void TokenizeStringSeparator( + const std::string& str, + const std::string& separator, + std::vector* 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* results) const { + results->clear(); + TokenizeStringSeparator(Convert(id), " ||| ", results); +} + -- cgit v1.2.3