PYTHON (2.7) Question texts: https://drive.google.com/folderview?id=0Bz_aB61VIRZ
ID: 667047 • Letter: P
Question
PYTHON (2.7) Question
texts:
https://drive.google.com/folderview?id=0Bz_aB61VIRZAfnNoamZmZVdVR19TNmdmVDBwbk5aN1JsNkQyNTVRLUgwVVB2elVIUHBfcFE&usp=sharing
Please check the codes by using the example text file in given link. And take screenshot the output.
Assignment Description The goal of this assignment is, given an input text file, use a Markov Chain algorithm to restructure the text, and save the results to another text file A Markov Chain is a way to predict "what to do next" based on "what you did recently" (the details of the process can be found on http://en.wikipedia.org/wiki/Markov_chain) A Markov Chain maintains a fixed series of states, and based on those states determines what to do next, something like walking through a path. The number of steps that are remembered is fixed at the beginning of the process Such a method can easily be applied to bodies of text to create, humorous constructions of reasonably sensible sentences. This construction is based on the sampling of existing text to create a Markov chain. An existing document is scanned, observing the previous n words, and remembering the word that follows. Using this information, one can create a new document based on the Markov chain created from the previous document In this assignment, you are asked to construct a Markov chain that represents a Markov chain of a document given as input to vour program. For the purpose of the assiqnment you can set the value of n to two. Thus, for every word in the given document, you should record and keep in an appropriate data structure, the previous two words in the document (Please note that, same two word combination may occur before several different words in the same document; hence your data structure should be able to handle a list of words corresponding to the same word pairs) To create a new text document, the process begins by selecting the first two words from the original text file as the first two words of the new document. The word recorded originally corresponding to this two word combination will be the third word of the new document. If there are more than one words corresponding to the two word combination, then one of them is selected as randomly. Then, the second and third words from the new document are selected to form a pair, and the word recorded originally corresponding toExplanation / Answer
markov_model.py
markov_temp.py
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.