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
commit2cc482a64c687ef9505449e903776a1f1e595343 (patch)
tree57f666d208646824b12a70795dd3c50b9c05f883 /decoder
parentf7935125ba51a0f84def04c25e14ccdbdc5fb7b7 (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);
}