Make Markov bot unescape strings

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-16 12:21:25 +01:00
parent d8c07f33a5
commit 2408d2c7ae

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import dbtools, twitools
import argparse, markovify, nltk, operator, random, re, sys
import argparse, html, markovify, nltk, operator, random, re, sys
class Possy(markovify.NewlineText):
def word_split(self, sentence):
@ -17,7 +17,7 @@ def getText(db = dbtools.dbHelper()):
text = ""
for string in db.executeQuery('SELECT text FROM tweets WHERE text NOT LIKE "@%" AND text NOT LIKE "RT %";'):
text += string[0] + "\n"
return "".join([s for s in text.strip().splitlines(True) if s.strip()])
return html.unescape("".join([s for s in text.strip().splitlines(True) if s.strip()]))
def markovifyText(text):
return Possy(text).make_short_sentence(130).replace("@", "@")