28 lines
782 B
Python
28 lines
782 B
Python
import markovify,os
|
|
|
|
# on by default, if it lags turn it off
|
|
RETAIN_ORIGINAL = True
|
|
|
|
combined_model = None
|
|
for corpus in os.listdir("corpora"):
|
|
with open(os.path.join("corpora",corpus)) as f:
|
|
model = markovify.Text(f.read(),retain_original=RETAIN_ORIGINAL)
|
|
if combined_model:
|
|
combined_model = markovify.combine(models=[combined_model,model])
|
|
else:
|
|
combined_model = model
|
|
|
|
stage_directions = None
|
|
with open("stagedirections.txt") as f:
|
|
stage_directions = markovify.Text(f.read())
|
|
|
|
def make_direction(*args,**kwargs):
|
|
return stage_directions.make_sentence(*args,**kwargs)
|
|
|
|
def make_sentence(*args,**kwargs):
|
|
return combined_model.make_sentence(*args,**kwargs)
|
|
|
|
if __name__=="__main__":
|
|
print(make_direction(tries=100))
|
|
print(combined_model.make_sentence(tries=100))
|