kaldi::internal Namespace Reference

Functions

bool LocateSymbolRange (const std::string &trace_name, size_t *begin, size_t *end)
 

Function Documentation

◆ LocateSymbolRange()

bool LocateSymbolRange ( const std::string &  trace_name,
size_t begin,
size_t end 
)

Definition at line 79 of file kaldi-error.cc.

References rnnlm::i.

Referenced by kaldi::VerifySymbolRange().

80  {
81  // Find the first '_' with leading ' ' or '('.
82  *begin = std::string::npos;
83  for (size_t i = 1; i < trace_name.size(); i++) {
84  if (trace_name[i] != '_') {
85  continue;
86  }
87  if (trace_name[i - 1] == ' ' || trace_name[i - 1] == '(') {
88  *begin = i;
89  break;
90  }
91  }
92  if (*begin == std::string::npos) {
93  return false;
94  }
95  *end = trace_name.find_first_of(" +", *begin);
96  return *end != std::string::npos;
97 }