summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-10 20:03:53 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-10 20:03:53 +0000
commit963b7b96576de000a743ef377c439ea5c6787e2e (patch)
treec44b113de22473a74b831867dd2c8fed8d4d56f4 /decoder
parent86ae2fcf6207630c03ec222131346a6fd8fee10a (diff)
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
Diffstat (limited to 'decoder')
-rw-r--r--decoder/dict.cc22
1 files changed, 19 insertions, 3 deletions
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 <string>
#include <vector>
-#include <boost/regex.hpp>
-#include <boost/algorithm/string/regex.hpp>
+
+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 {
- boost::algorithm::split_regex(*results, Convert(id), boost::regex("\\s\\|\\|\\|\\s"));
+ results->clear();
+ TokenizeStringSeparator(Convert(id), " ||| ", results);
}