r/CodingHelp • u/OperationVisual6523 • 6d ago
[C++] Part two of my Markov Chain Project
Hey there! So i figured how to do the lottery system for my markov chain but im getting stuck on how to initialize it. what im trying to do is im trying to get the first two words and get them to predict the third word coming. But i dont know how to do it so far and this is what i have. I just kinda threw stuff at the wall till it stuck but yeah this is what i have so far. Thanks
I cant figure out the stupid code format on reddit for mobile, sorry in advanced.
void MarkovChain::initializeChains(const vector<string>& words) { //(void)words; // fill me in
map<list<string>, map<string, int>> token;
map<string, int> ngram;
for (const auto& word : words) {
list<string> key(words.begin(), words.end());
token[key][word]++;
}}
•
u/AutoModerator 6d ago
Thank you for posting on r/CodingHelp!
Please check our Wiki for answers, guides, and FAQs: https://coding-help.vercel.app
Our Wiki is open source - if you would like to contribute, create a pull request via GitHub! https://github.com/DudeThatsErin/CodingHelp
We are accepting moderator applications: https://forms.fillout.com/t/ua41TU57DGus
We also have a Discord server: https://discord.gg/geQEUBm
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.