Skip to content

Instantly share code, notes, and snippets.

@thesauri
Created September 24, 2019 20:16
Show Gist options
  • Save thesauri/a35523494a3163e1489985a9f4eccfb3 to your computer and use it in GitHub Desktop.
Save thesauri/a35523494a3163e1489985a9f4eccfb3 to your computer and use it in GitHub Desktop.
import markovify
import sys
if len(sys.argv) < 2:
print("tinder.py chat-file.txt")
exit(1)
chat_file = sys.argv[1]
# Get raw text as string.
with open(chat_file) as f:
text = f.read()
# Build the model.
text_model = markovify.Text(text)
# Print five randomly-generated sentences
for i in range(5):
print(text_model.make_sentence(test_output=False))
# Print three randomly-generated sentences of no more than 280 characters
for i in range(3):
print(text_model.make_short_sentence(280))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment