Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions