Skip to content

Instantly share code, notes, and snippets.

@j0hn
Created July 22, 2015 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j0hn/5b6e2eb047349be0d1f0 to your computer and use it in GitHub Desktop.
Save j0hn/5b6e2eb047349be0d1f0 to your computer and use it in GitHub Desktop.
Bot de cadenas de markov
# -*- 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))
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment