We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d715db5 commit 1b81d18Copy full SHA for 1b81d18
1 file changed
test.py
@@ -3,27 +3,17 @@
3
from markov import MarkovChar, MarkovWord
4
5
if __name__ == '__main__':
6
-
7
fname = "./datatxt/sherlock_holmes.txt"
8
9
if(sys.version_info[0] < 3):
10
- # Python 2
11
with open(fname, "r") as f:
12
x = f.read().decode("UTF-8")
13
else:
14
- # Python 3
15
with open(fname, "r", encoding="utf-8") as f:
16
x = f.read()
17
18
mc = MarkovChar(6)
19
20
mc.learn(x)
21
22
print(textwrap.fill(mc.generate(500), width=72))
23
24
mw = MarkovWord(2)
25
26
mw.learn(x)
27
28
print(textwrap.fill(mw.generate(100), width=72))
29
0 commit comments