-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.py
More file actions
30 lines (24 loc) · 780 Bytes
/
generator.py
File metadata and controls
30 lines (24 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import markovify
import glob
# use 3 or even 2 to add more nonsense. using 5 will eliminate cross-corpora sentences. so 4 is optimal
STATE_SIZE = 4
SENTENCES = 1000
models = []
for filename in glob.glob("corpus-programming/*.txt"):
print('Loading file:', filename)
with open(filename) as f:
models.append(markovify.Text(f.read(), state_size=STATE_SIZE))
for filename in glob.glob("corpus-veda/*.txt"):
print('Loading file:', filename)
with open(filename) as f:
models.append(markovify.Text(f.read(), state_size=STATE_SIZE))
model = markovify.combine(models)
i = 0
while i < SENTENCES:
sentence = model.make_sentence()
if sentence is None:
continue
i += 1
print(sentence)