Question: PYTHON ONLY! PLEASE FOLLOW DIRECTIONS! DIRECTIONS: import stdio import sys from markov_model import MarkovModel # Takes two integers k and T as command-line arguments, reads

PYTHON ONLY! PLEASE FOLLOW DIRECTIONS!

PYTHON ONLY! PLEASE FOLLOW DIRECTIONS! DIRECTIONS: import stdio import sys from markov_model

DIRECTIONS:

import stdio import sys from markov_model import MarkovModel

# Takes two integers k and T as command-line arguments, reads the input text # from standard input 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. def main(): ...

if __name__ == '__main__': main()

Hints

Read command-line arguments k and T

Initialize text to text read from standard input using sys.stdin.read()

Create a Markov model model using text and k

Use model.gen() to generate a random text of length T and starting with the first k characters of text

Write the random text to standard output

Problem 2. (Random Tert 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 T2 k s python text-generator.py 2 50 data/input17.txt gaggcgaggcgagagagaaaagaaaggcgaaggagagaggagaggaggcg

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!