-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
37 lines (31 loc) · 863 Bytes
/
generate.py
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
31
32
33
34
35
36
37
import random
def generate(start, length, def_dict):
sentence = start
curr_len = 1
word = start
while curr_len < length:
frequencies = list(def_dict[word].values())
need = random.choice(frequencies)
for j in def_dict[word].keys():
if def_dict[word][j] == need:
word = j
break
sentence += ' ' + word
curr_len += 1
return sentence
output_file = ''
link_to_save = ''
while True:
cmnd = input().split()
if cmnd[0] == 'exit':
break
elif cmnd[0] == '--output':
output_file = cmnd[1]
elif cmnd[0] == '--model':
link_to_save = cmnd[1]
elif cmnd[0] == '--seed':
start = cmnd[1]
elif cmnd[0] == '--length':
length = int(cmnd[1])
elif cmnd[0] == '--help':
print('print "exit" to finish')