Add chain loader
This commit is contained in:
parent
25f7075304
commit
4ea6c0a7f6
|
@ -0,0 +1,19 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
def make_sentence(*args,**kwargs):
|
||||||
|
return combined_model.make_sentence(*args,**kwargs)
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
print(combined_model.make_sentence(tries=100))
|
Loading…
Reference in New Issue