Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mert
diff options
context:
space:
mode:
authorTetsuo Kiso <tetsuo-s@is.naist.jp>2011-11-13 16:13:44 +0400
committerTetsuo Kiso <tetsuo-s@is.naist.jp>2011-11-13 16:13:44 +0400
commit8f0ba037f387505a1deb87c0ac85c68d2de521b7 (patch)
treebb4697803b697543203fcb62461e7c47d9c0bcf7 /mert
parent3d70b2e1a5d66a6387b3b4fd023fc3bed2bb28a8 (diff)
Add comments.
Diffstat (limited to 'mert')
-rw-r--r--mert/Util.cpp14
-rw-r--r--mert/Util.h16
2 files changed, 21 insertions, 9 deletions
diff --git a/mert/Util.cpp b/mert/Util.cpp
index cded1f1ea..dc4824559 100644
--- a/mert/Util.cpp
+++ b/mert/Util.cpp
@@ -38,19 +38,19 @@ int setverboselevel(int v)
return verbose;
}
-size_t getNextPound(std::string &theString, std::string &substring, const std::string delimiter)
+size_t getNextPound(std::string &str, std::string &substr,
+ const std::string &delimiter)
{
size_t pos = 0;
// skip all occurrences of delimiter
while (pos == 0) {
- // if ((pos = theString.find(delimiter)) != std::string::npos) {
- if (FindDelimiter(theString, delimiter, &pos)) {
- substring.assign(theString, 0, pos);
- theString.erase(0, pos + delimiter.size());
+ if (FindDelimiter(str, delimiter, &pos)) {
+ substr.assign(str, 0, pos);
+ str.erase(0, pos + delimiter.size());
} else {
- substring.assign(theString);
- theString.assign("");
+ substr.assign(str);
+ str.assign("");
}
}
return pos;
diff --git a/mert/Util.h b/mert/Util.h
index 23e9e0c17..0880a7d3d 100644
--- a/mert/Util.h
+++ b/mert/Util.h
@@ -38,12 +38,24 @@ class FeatureStats;
#define TRACE_ERR(str) { }
#endif
-#define DELIMITER_SYMBOL " "
+const char kDefaultDelimiterSymbol[] = " ";
int verboselevel();
int setverboselevel(int v);
-size_t getNextPound(std::string &theString, std::string &substring, const std::string delimiter=DELIMITER_SYMBOL);
+/**
+ * Find the specified delimiter for the string 'str', and 'str' is assigned
+ * to a substring object that starts at the position of first occurrence of
+ * the delimiter in 'str'. 'substr' is copied from 'str' ranging from
+ * the start position of 'str' to the position of first occurrence of
+ * the delimiter.
+ *
+ * It returns the position of first occurrence in the queried string.
+ * If the content is not found, std::string::npos is returned.
+ */
+size_t getNextPound(std::string &str, std::string &substr,
+ const std::string &delimiter = kDefaultDelimiterSymbol);
+
void split(const std::string &s, char delim, std::vector<std::string> &elems);
void Tokenize(const char *str, const char delim, std::vector<std::string> *res);