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 an integer k (model order) and a string s

PYTHON ONLY PLEASE FOLLOW DIRECTIONS!

image text in transcribed

DIRECTIONS:

import stdio import sys from markov_model import MarkovModel

# Takes an integer k (model order) and a string s (noisy message) as # command-line arguments, reads the input text from standard input, and # prints out the most likely original string. def main(): ...

if __name__ == '__main__': main()

Problem 3. (Noisy Message Decoder) Imagine you receive a message where some of the ch noise. We represent unknown characters by the symbol (we assume we don't use in our messages). Implement the methood model.replace_unknon in the arkov_model.py data type that decodes a noisy message corrupted by replacing each -in it with the most likely character given an order k Markov model and conditional on the surrounding text and returns the decoded message. You may assume that the unknown characters are at least k characters apart and also appear at least k characters away from the start and end of the message. have been corrupted by This maximum-likelihood approach doesn't always get it perfect, but it fixes most of the missing characters correctly. Here are some details on what it means to find the most likely replacement for each . For each unknown character, you should consider all possible replacement characters. You want the replacement character that makes sense not only at the unknowin position (given the previous characters) but also when the replacement is used in the context of the k subsequent known characters. For example, we expect the unknown character in "vas he woto be and not simply the most likely character in the context of "vas ". You can compute the probability of each hypothesis by multiplying the probabilities of generating each of k +1 characters in sequence: the missing one, and the k next ones. Write a client program fix.corrupted.py that takes an integer k (model order) and a string s (noisy message) as command-line arguments, reads the input text from standard input (for efficiency reasons, use sys.stdin.read to read the text), and print:s out the most likely original string. Original Noisy : it vas the best of tines, it was the worst of tines : it vth be of tins, i' vas he wo st of tines python fix-corrupted. py 4 "it w-s th" bes- of tin-s, i was "he vo-st of-times."

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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago