From 2cc482a64c687ef9505449e903776a1f1e595343 Mon Sep 17 00:00:00 2001 From: redpony Date: Tue, 10 Aug 2010 20:03:53 +0000 Subject: support for running in multiple environments which are automatically detected git-svn-id: https://ws10smt.googlecode.com/svn/trunk@501 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/dict.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'decoder/dict.cc') diff --git a/decoder/dict.cc b/decoder/dict.cc index 4a842f82..2d6986c8 100644 --- a/decoder/dict.cc +++ b/decoder/dict.cc @@ -2,10 +2,26 @@ #include #include -#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 { - boost::algorithm::split_regex(*results, Convert(id), boost::regex("\\s\\|\\|\\|\\s")); + results->clear(); + TokenizeStringSeparator(Convert(id), " ||| ", results); } -- cgit v1.2.3