20 #ifndef KALDI_UTIL_TEXT_UTILS_H_ 21 #define KALDI_UTIL_TEXT_UTILS_H_ 43 bool omit_empty_strings,
44 std::vector<std::string> *out);
51 const char *delim,
bool omit_empty_strings,
52 std::string *str_out);
70 bool omit_empty_strings,
73 std::vector<I> *out) {
76 if (*(full.c_str()) ==
'\0') {
80 std::vector<std::string> split;
82 out->resize(split.size());
83 for (
size_t i = 0;
i < split.size();
i++) {
84 const char *this_str = split[
i].c_str();
88 if (end == this_str || *end !=
'\0') {
92 I jI =
static_cast<I
>(
j);
93 if (static_cast<int64>(jI) !=
j) {
108 bool omit_empty_strings,
109 std::vector<F> *out);
121 const char *this_str = str.c_str();
126 while (isspace(*end)) end++;
127 if (end == this_str || *end !=
'\0' || errno != 0)
129 Int iInt =
static_cast<Int
>(
i);
130 if (static_cast<int64>(iInt) != i ||
131 (i < 0 && !std::numeric_limits<Int>::is_signed)) {
143 template <
typename T>
148 void Trim(std::string *str);
163 bool IsToken(
const std::string &token);
168 bool IsLine(
const std::string &line);
183 const std::string &b,
184 int32 decimal_places_check = 2);
216 bool GetValue(
const std::string &key, std::string *value);
220 bool GetValue(
const std::string &key, std::vector<int32> *value);
221 bool GetValue(
const std::string &key,
bool *value);
240 std::map<std::string, std::pair<std::string, bool> >
data_;
248 const std::string &token1,
249 const std::string &token2);
258 std::vector<std::string> *lines);
271 std::vector<ConfigLine> *config_lines);
281 #endif // KALDI_UTIL_TEXT_UTILS_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool ConvertStringToInteger(const std::string &str, Int *out)
Converts a string into an integer via strtoll and returns false if there was any kind of problem (i...
const std::string & FirstToken() const
const std::string WholeLine()
bool ParseLine(const std::string &line)
bool SplitStringToFloats(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< F > *out)
#define KALDI_ASSERT_IS_INTEGER_TYPE(I)
bool IsLine(const std::string &line)
Returns true if "line" is free of characters and unprintable characters, and does not contain leadi...
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g.
void JoinVectorToString(const std::vector< std::string > &vec_in, const char *delim, bool omit_empty_strings, std::string *str_out)
Joins the elements of a vector of strings into a single string using "delim" as the delimiter...
bool IsValidName(const std::string &name)
Returns true if 'name' would be a valid name for a component or node in a nnet3Nnet.
bool IsToken(const std::string &token)
Returns true if "token" is nonempty, and all characters are printable and whitespace-free.
void ExpectOneOrTwoTokens(std::istream &is, bool binary, const std::string &token1, const std::string &token2)
This function is like ExpectToken but for two tokens, and it will either accept token1 and then token...
std::string UnusedValues() const
returns e.g.
bool StringsApproxEqual(const std::string &a, const std::string &b, int32 decimal_places_tolerance)
This function returns true when two text strings are approximately equal, and false when they are not...
void SplitStringOnFirstSpace(const std::string &str, std::string *first, std::string *rest)
Removes leading and trailing white space from the string, then splits on the first section of whitesp...
void SplitStringToVector(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< std::string > *out)
Split a string using any of the single character delimiters.
bool ConvertStringToReal(const std::string &str, T *out)
ConvertStringToReal converts a string into either float or double and returns false if there was any ...
void ReadConfigLines(std::istream &is, std::vector< std::string > *lines)
This function reads in a config file and *appends* its contents to a vector of lines; it is responsib...
void Trim(std::string *str)
Removes the beginning and trailing whitespaces from a string.
This class is responsible for parsing input like hi-there xx=yyy a=b c empty= f-oo=Append(bar, sss) ba_z=123 bing='a b c' baz="a b c d='a b' e" and giving you access to the fields, in this case.
#define KALDI_ASSERT(cond)
bool HasUnusedValues() const
void ParseConfigLines(const std::vector< std::string > &lines, std::vector< ConfigLine > *config_lines)
This function converts config-lines from a simple sequence of strings as output by ReadConfigLines()...
bool GetValue(const std::string &key, std::string *value)
#define KALDI_STRTOLL(cur_cstr, end_cstr)
std::map< std::string, std::pair< std::string, bool > > data_