def main(): """ Executes a MarkovChain for text generation. Then it will be wait for user input. If length of user input less than `window` parameter of the chain, then random text will be generated, else last 3 words of the input will be taken as a start of generated text. If you want break the process, then enter `48598ee283437e810f2f0eb1cf66e217`. """ chain = MarkovChain() # path relative to command line that executes that script. chain.chain = extensions.file.json.read("./src/markov-chain/generated-chains/ru/my-favorites-3-window.json") while True: start_text = input() if (start_text == "48598ee283437e810f2f0eb1cf66e217"): break # 3 - how many windows in the chain. start_text = handle_input_text(start_text, 3) if (start_text): print(chain.generate(start=start_text)) else: print(chain.generate())
from markov_chain import MarkovChain markov_chain = MarkovChain() text = '' chain = markov_chain.chain(text) print(chain)