mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Add comments.
This commit is contained in:
parent
3d70b2e1a5
commit
8f0ba037f3
@ -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;
|
||||
|
16
mert/Util.h
16
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);
|
||||
|
Loading…
Reference in New Issue
Block a user