Open yorkshirelandscape opened 2 years ago
Hi @yorkshirelandscape, and glad the library's been working well for you! Just thinking through how Markov chains work (aside from the particular implementation here), I'm not aware of a way to involve a fallback without building that additional model. But if other folks have ideas for that, I'd be interested to hear them.
I'm trying to build a Slack chatbot using bits and pieces of code I've found lying around on the internet. One of them included markovify and it's just about the only thing from it that worked! I was wondering, though, if there's a way to fall back to a smaller state_size without building an entire fallback model. What I've done in the interim is create 2- and 1-word models. If the 2-word init_state key isn't in the model, it tries the 1-word model with the first word of the key. Failing that, it just lets it come up with something without the init_state argument. I'm sure that as my corpus gets larger, this is going to become unwieldy. I hope this is possible without making any changes to the codebase, but hope you'll consider it, either way.
Thanks for writing this!