import markovify

text = ""
# Get raw text as string.
with open("poems.txt") as f:
    text = f.read()

# Build the model.
text_model = markovify.Text(text)

# Print five randomly-generated sentences
# Print three randomly-generated sentences of no more than 140 characters
for j in range(1, 300):
	with open('generated.txt', 'a') as the_file:
			the_file.write("[" + "\n")
	for i in range(15):
		thing = text_model.make_short_sentence(50)
		
		try:
			if i == 14:
				with open('generated.txt', 'a') as the_file:
					the_file.write("\"" + thing + "\"" + "\n")
			else:
				with open('generated.txt', 'a') as the_file:
					the_file.write("\"" + thing + "\"," + "\n")
		except Exception as e:
			pass
	with open('generated.txt', 'a') as the_file:
			the_file.write("]," + "\n")
	print(j)