Integrate changes
This commit is contained in:
commit
8a2c09696a
|
@ -24,9 +24,6 @@ def postprocess(lid, tid, db = dbtools.dbHelper()):
|
|||
db.executeQuery("UPDATE lyrics SET active = 1 WHERE ref = %i;" % int(lid))
|
||||
db.commit()
|
||||
|
||||
def tweet(text, ref = 0, two = twitools.twoHelper(setuptools.LYRICS)):
|
||||
return two.tweet(text, ref).id
|
||||
|
||||
if __name__ == "__main__":
|
||||
lid, text, ref = getLyrics()
|
||||
postprocess(lid, tweet(text, ref))
|
||||
postprocess(lid, twitools.tweet(text, ref, setuptools.LYRICS))
|
||||
|
|
26
markov.py
26
markov.py
|
@ -1,16 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import dbtools, setuptools, twitools
|
||||
import argparse, markovify, operator, random, re, sys
|
||||
import argparse, html, markovify, nltk, operator, random, re, sys
|
||||
|
||||
class Possy(markovify.NewlineText):
|
||||
def word_split(self, sentence):
|
||||
words = re.split(self.word_split_pattern, sentence)
|
||||
words = [ "::".join(tag) for tag in nltk.pos_tag(words) ]
|
||||
return words
|
||||
|
||||
def word_join(self, words):
|
||||
sentence = " ".join(word.split("::")[0] for word in words)
|
||||
return sentence
|
||||
|
||||
def getText(db = dbtools.dbHelper()):
|
||||
return '\n'.join(db.executeQuery("SELECT text FROM tweets;"))
|
||||
text = ""
|
||||
for string in db.executeQuery('SELECT text FROM tweets WHERE text NOT LIKE "@%" AND text NOT LIKE "RT %";'):
|
||||
text += string[0] + "\n"
|
||||
return html.unescape("".join([s for s in text.strip().splitlines(True) if s.strip()]))
|
||||
|
||||
def markovify(text):
|
||||
return markovify.Text(text).make_short_sentence(130).replace("@", "@")
|
||||
|
||||
def tweet(text, ref = 0, two = twitools.twoHelper(setuptools.MARKOV)):
|
||||
return two.tweet(text, ref).id
|
||||
def markovifyText(text):
|
||||
return Possy(text).make_short_sentence(130).replace("@", "@")
|
||||
|
||||
if __name__ == "__main__":
|
||||
tweet(markovify(getText()))
|
||||
twitools.tweet(markovifyText(getText()), section = setuptools.MARKOV)
|
||||
|
|
|
@ -47,3 +47,6 @@ def twoHelper(section = setuptools.TWITTER):
|
|||
return twObject(ato = setuptools.ato(section), ase = setuptools.ase(section))
|
||||
except:
|
||||
return twObject()
|
||||
|
||||
def tweet(text, ref = 0, section = setuptools.TWITTER):
|
||||
return twoHelper(section).tweet(text, ref).id
|
||||
|
|
Loading…
Reference in a new issue