Category : parsing

Hi I am working with existing C++ code, I normally use VB.NET and much of what I am seeing is confusing and contradictory to me. The existing code loads neural network weights from a file that is encoded as follows: 2 model.0.conv.conv.weight 5 3e17c000 3e9be000 3e844000 bc2f8000 3d676000 model.0.conv.bn.weight 7 4006a000 3f664000 3fc98000 3fa6a000 3ff2e000 ..

Read more

When we have a list in python like below : python_list = [["A","B","C"],["D","E","F"],["G","H","I"],…,["X","Y","Z"]] it’s easy and flexible to get the element we want like element "D" we can use ‘python_list[1][0]’ get it. But what if I have a string like the one’python_list’ in c++, what’s the simplest way to parse out the list-like string into ..

Read more

int main() { std::string s = "my name is joe"; std::stringstream ss{s}; std::string temp; while(std::getline(ss, temp, ‘ ‘)) { cout << temp.size() << " " << temp << endl; } //—————————-// ss = std::stringstream{s}; while(ss >> temp) { cout << temp.size() << " " << temp << endl; } } I’ve always used the former, ..

Read more

I am trying to split sentences apart by punctuation (".","?","!"). I have found on stack overflow a way to separate a string by one delimiter, but I have not been able to find a way to seperate a string based on multiple delimiters at once. Here is the code I have so far. void chopSentences(std::string ..

Read more

I have to split data from an external stream by a predefined pattern (for example "——"). I do not know how many items will be in the stream, but I know the whole length of it (or I can get some mark on the end of data). I am using the following function to read ..

Read more