Created
July 22, 2015 14:20
-
-
Save j0hn/5b6e2eb047349be0d1f0 to your computer and use it in GitHub Desktop.
Bot de cadenas de markov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import markovify | |
import codecs | |
# Get raw text as string. | |
with codecs.open("corpus.txt", encoding="utf-8") as f: | |
text = f.read() | |
# Build the model. | |
text_model = markovify.Text(text) | |
# Generate 10 sentences with a maximun of 140 characters | |
for i in range(10): | |
print(text_model.make_short_sentence(140)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment