r/AskProgramming • • 11h ago

C/C++ Markovs Chains, initializeChains part 2

1 Upvotes

Okay so I figured out how to utilze the chain to like do things with instead of just reading word by word but im still getting failues in testing. I dont know if its correct or not honestly.

void MarkovChain::initializeChains(const vector<string>& words) {

//(void)words;

// fill me in

map<list<string>, map< string, int>> token;

for (size_t i = 0; i <= words.size() - 3; i++) {

list<string> key{ words\[i\], words\[i + 1\] };

token\[key\]\[words\[i + 2\]\]++;

}