Question: Problem 2. (Random Text Generator ) Write a client program text_generator.py that takes two command-line integers k and T, reads the input text from standard
Problem 2. (Random Text Generator ) Write a client program text_generator.py that takes two command-line integers k and T, reads the input text from standard input (for efficiency reasons, use sys.stdin.read() to read the text) and builds a Markov model of order k from the input text; then, starting with the k-gram consisting of the first k characters of the input text, prints out T characters generated by simulating a trajectory through the corresponding Markov chain, followed by a new line. You may assume that the text has length at least k, and also that T ? k. $
python3 text_generator . py 2 50 < data / input17 . txt gaggcgaggcgagagagaaaagaaaggcgaaggagagaggagaggaggcg
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
