def markov_tweet():
    """ Generates a tweet using a Markov bot. """
    bot = MarkovBot()
    read_book(bot, 'alice.txt')
    read_book(bot, 'dao.txt')
    read_book(bot, 'pride.txt')
    read_book(bot, 'sherlock.txt')
    read_book(bot, 'oz.txt')

    seed_words = ['drink', 'health', 'water', 'river', 'stream']
    tweet_content = bot.generate_text(15, seedword=seed_words)
    print tweet_content

    # Check if the generated content has a seed word in it.
    for word in seed_words:
        if word in tweet_content:
            return tweet_content + ' #DrinkWater'
    return None
Beispiel #2
0
def markov():
    tweetbot = MarkovBot()
    dirname = os.path.dirname(os.path.abspath(__file__))
    data1 = os.path.join(dirname, 'positiveTweets.txt')
    data2 = os.path.join(dirname, '1liner.txt')
    data3 = os.path.join(dirname, '10ondate.txt')
    data4 = os.path.join(dirname, 'forCachetes.txt')
    #data5 = os.path.join(dirname, 'book3.txt')
    #data6 = os.path.join(dirname, 'book4.txt')
    data7 = os.path.join(dirname, 'jokes.txt')
    #data8 = os.path.join(dirname, 'book4.txt')
    tweetbot.read(data1)
    tweetbot.read(data2)
    tweetbot.read(data3)
    tweetbot.read(data4)
    #tweetbot.read(data5)
    #tweetbot.read(data6)
    tweetbot.read(data7)
    #tweetbot.read(data8)

    my_first_text = tweetbot.generate_text(25, seedword=['life', 'motivation', 'happy', 'bullying'])
    print("tweetbot says:")
    print(my_first_text)
Beispiel #3
0
import os
from markovbot import MarkovBot
import json

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, 'The Dhammapada.txt')
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['way', 'He'])
print("tweetbot says:")
print(my_first_text)

json_data = {}

with open("config.json") as json_file:
    json_data = json.loads(json_file.read())
    print(json_data)

consumer_key = json_data['consumer_key']
consumer_secret = json_data['consumer_secret']
access_token = json_data['access_token']
access_token_secret = json_data['access_token_secret']
tweetbot.twitter_login(consumer_key, consumer_secret, access_token,
                       access_token_secret)

targetstring = 'Buddhism'
keywords = ['man', 'always', 'truth', 'ignorant', 'lives']
prefix = None
suffix = '#BuddhismSays'
Beispiel #4
0
fFour = (fThree.replace("ACT", " "))
finalDataShake = fFour
'''
'''freud'''
''' 
i need to clean this up a lot and add organon
- make methods more recycle --> code is stale
- many authors at once with func 
- add learning method --> possible neural net? I want to make training worthwhile....
- add a score to output? compare results to text --> give score and only release the 'good' ones -> but also tell the model that it did a good or bad job
'''

dirname = os.path.dirname(os.path.abspath(__file__))
freudText = os.path.join(dirname, 'training_txt/freudCompleteWorks.txt')
bot.read(freudText)
freudTweets = bot.generate_text(25)
'''
fTwo = (re.sub('[-,_[@?#*"%;()}0-9]', " ", data))
fThree = (fTwo.replace("SCENE" "ACT", " "))
finalSText = fThree'''
''' really????? this is no good, going to fix this week '''
shakeText = os.path.join(dirname, 'training_txt/shakeComplete.txt')
bot2.read(shakeText)
shakeTweets = bot2.generate_text(25)

west_phil_text = os.path.join(dirname, 'training_txt/westPhil.txt')
bot4.read(west_phil_text)
westp_text = bot4.generate_text(25)

russellText = os.path.join(dirname, 'rtraining_txt/russelMath.txt')
bot3.read(russellText)
    while(tweetStr_2 == ""):
        if sentenceKey[dictNo].has_key(rowResponse['rows'][0][column]):
            tweetStr_2 = sentenceKey[dictNo][rowResponse['rows'][0][column]]
        else:
            column = randint(8,27)

    tweetStr = tweetStr_1 + tweetStr_2
    return tweetStr

while True:
    tweetStr = GetTweetStr(service)
    api.update_status(tweetStr)
    time.sleep(3600)

# Markovbot for automated replies
tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, u'ebook.txt')
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=[u'economy', u'money'])
print(u'\ntweetbot says: "%s"' % (my_first_text))

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)

#Start tweeting periodically
tweetbot.twitter_tweeting_start(days=0, hours=0, minutes=1, keywords=None, prefix=None, suffix=None)

Beispiel #6
0
import os
from markovbot import MarkovBot

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
print(dirname)
# Construct the path to the book
book = os.path.join(dirname, 'hotep_speak.txt')
# Make your bot read the book!
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['black', 'america'])
print("tweetbot says:")
print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = 'K9YqNYb8j6HA0hgBKLZ1aQ918'
# Consumer Secret (API Secret)
cons_secret = 'BFCDji7mF7sfw2PpdQMEcZ90Poht5E6OMff1XEHb3UeLB8K1Fz'
# Access Token
access_token = '988043632828715008-U4kAofzutxFuPx6c3jCwnrRztm3y5lt'
# Access Token Secret
access_token_secret = 'zNxtfZQb9HU3nRN88uJzJ39H2Ttfk7Vno0Qc3WobX0U5J'

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
Beispiel #7
0
# Construct the path to the book
book = os.path.join(dirname, u'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)


# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'dream', u'psychoanalysis'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))


# # # # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# ALL YOUR SECRET STUFF!
# Make sure to replace the ''s below with your own values, or try to find
# a more secure way of dealing with your keys and access tokens. Be warned
# that it is NOT SAFE to put your keys and tokens in a plain-text script!
Beispiel #8
0
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'smith_wealth_of_nations.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'labour', u'capital'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))

# # # # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# ALL YOUR SECRET STUFF!
# Make sure to replace the ''s below with your own values, or try to find
# a more secure way of dealing with your keys and access tokens. Be warned
# that it is NOT SAFE to put your keys and tokens in a plain-text script!
Beispiel #9
0
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'onion_headlines_filtered.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(maxlength=15)

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))
"""
# # # # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# ALL YOUR SECRET STUFF!
# Make sure to replace the ''s below with your own values, or try to find
# a more secure way of dealing with your keys and access tokens. Be warned
# that it is NOT SAFE to put your keys and tokens in a plain-text script!
Beispiel #10
0
import os
from markovbot import MarkovBot

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
headline = os.path.join(dirname, 'hosking_headlines.txt')
comment = os.path.join(dirname, 'hosking_comments.txt')

gen = input('Generate headline? Y/N\n')
while True:
    if gen == 'Y' or gen == 'y':
        tweetbot.read(headline)
        gen_head = tweetbot.generate_text(10)
        print(u'\nMike Hosking: %s' % (gen_head))

        tweetbot.clear_data()
        tweetbot.read(comment)
        gen_comm = tweetbot.generate_text(30)
        print('COMMENT: %s' % (gen_comm))
        gen = input(u'\nGenerate headline? Y/N\n')

    elif gen == 'N' or gen == 'n':
        exit()

    elif gen != 'Y' and gen != 'N' and gen != 'y' and gen != 'n':
        print(u'\nInput was not Y or N')
        gen = input(u'\nGenerate headline? Y/N\n')
import time
import sys
from markovbot import MarkovBot

reload(sys)
sys.setdefaultencoding('utf-8')

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Make your bot read the book!
tweetbot.read(
    'https://github.com/gini10/akelarreciberfeminista/blob/master/bots/ZorraMutante.py'
)

my_first_text = tweetbot.generate_text(
    10, seedword=[u'código', u'límite', u'hay'])
print(u'\ntweetbot says: "%s"' % (my_first_text))

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = '[ copy this value from Consumer Settings ]'
# Consumer Secret (API Secret)
cons_secret = '[ copy this value from Consumer Settings ]'
# Access Tokenf
access_token = '[ copy this value from Your Access Token ]'
# Access Token Secret
access_token_secret = '[ copy this value from Your Access Token ]'

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
Beispiel #12
0
import os
import time
from markovbot import MarkovBot
tweetbot = MarkovBot()
dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, 'manifesto.txt')
tweetbot.read(book)
my_text = tweetbot.generate_text(25, seedword=['society', 'bourgeoisie'])
print(my_text)

# Consumer Key (API Key)
cons_key = 'TIShdZ9JgpYIyg8X4oJXAzgFq'
# Consumer Secret (API Secret)
cons_secret = 'qgLQKTadisYeb1T7DIVPNs17U7ce0LUaCAofHss8fiDWDMugpx'
# Access Token
access_token = '1087385094858387459-DijdGpPcFmugx0L86msnc5TOeXj8Gh'
# Access Token Secret
access_token_secret = 'XUAoW9ieporFcgqE1wMJnHEag4rpurUwJzewP7XCkhPgq'
#log in to twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
#set parameters for auto-replies
targetstring = "capitalism"
keywords = ['cultural', 'economics', 'proletariat', 'bourgeoisie']
prefix = None
suffix = None
maxconvdepth = 1
#start auto-replies
tweetbot.twitter_autoreply_start(targetstring,
                                 keywords=keywords,
                                 prefix=prefix,
Beispiel #13
0
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'cleaner.trumptweets.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(
    25, seedword=[u'loser', u'sad', u'china', u'covfefe'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))

# # # # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# ALL YOUR SECRET STUFF!
# Make sure to replace the ''s below with your own values, or try to find
# a more secure way of dealing with your keys and access tokens. Be warned
# that it is NOT SAFE to put your keys and tokens in a plain-text script!
Beispiel #14
0
import os
import time
from markovbot import MarkovBot

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, 'Communist_Manifesto.txt')
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['communist', 'bourgoise'])
print("tweetbot says: ")
print(my_first_text)

cons_key = '' #Twitter access tokens go here
cons_secret = '' #Twitter access tokens go here
access_token = '' #Twitter access tokens go here
access_token_secret = '' #Twitter access tokens go here

tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)

targetstring = '#KarlMarx'
keywords = ['communism', 'bourgoise', 'proleterian', 'proleteriat', 'marx', 'socialism']
prefix = 'Karl Marx Here!'
suffix = '#BleepBloop'
maxconvdepth = 2

tweetbot.twitter_autoreply_start(targetstring, keywords=keywords, prefix=prefix, suffix=suffix, maxconvdepth=maxconvdepth)
tweetbot.twitter_tweeting_start(days=0, hours=1, minutes=0, keywords=None, prefix=None, suffix=None)

secsinweek = 7 * 24 * 60 * 60
from random import randint
from markovbot import MarkovBot
import os

bot = MarkovBot()

book = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                    'realdonaldtrump.txt')

# Make your bot read the text!
bot.read(book)

# Choose how many tweets you want to generate
tweets_to_generate = 150

for x in range(0, tweets_to_generate):
    # len of the new tweets that will be generated, in words
    tweet_len = randint(10, 25)
    # generating tweet, based on its len and seedwords!
    tweet = bot.generate_text(tweet_len, seedword=[])

    # writting to our generated sentences to the file the poster will use later
    sentences_list = open("generated_sentences.txt", "a")
    sentences_list.write(tweet + "\n")
    sentences_list.close()
Beispiel #16
0
#import twitter

#initalise a MarkovBot instance
tweetbot = MarkovBot()

#get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))

#construct the path to the book
book = os.path.join(dirname, 'sherlock.txt')

#make your bot read the book!
tweetbot.read(book)


my_first_text = tweetbot.generate_text(25, seedword=['Irene', 'watson','Mycroft'])
print("tweetbot says:")
print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = 'AqYyIzu5jXXYhubZI83WtfmnV'
# Consumer Secret (API Secret)
cons_secret = 'QyqofLZtVJSjgS4L7EltzaxPJrcz23vgyN8zMNZ4dm88HdM1c6'
# Access Token
access_token = '751058612051648514-FGw6PEjNmkIdbWqrC3MfhVYEe8KJyCF'
# Access Token Secret
access_token_secret = 'PFKpoM7ra8rziOc0gs9ci4pT2TGRvn0fRXw5gw8PzYFnp'

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)
import os, ssl

print os.environ['cons_key']
print os.environ['cons_secret']
print os.environ['access_token']
print os.environ['access_token_secret']

from markovbot import MarkovBot
#Initialize a MarkovBot instance
tweetbot = MarkovBot()
dirname = os.path.dirname(os.path.abspath("tmg copy.text"))
# Construct the path to the book
book = os.path.join(dirname, 'tmg copy.text')
# Make your bot read the book!
tweetbot.read(book)
my_first_text = tweetbot.generate_text(25,
                                       seedword=[
                                           'you',
                                           'I am',
                                           'going to',
                                           'my',
                                           'love',
                                       ])
print(my_first_text)
tweetbot.twitter_login(os.environ['cons_key'], os.environ['cons_secret'],
                       os.environ['access_token'],
                       os.environ['access_token_secret'])
# Start periodically tweeting
#tweetbot.twitter_tweeting_start(days=0, hours=0, minutes=5 keywords=None, prefix=None, suffix=None)
tweetbot._t.statuses.update(status=my_first_text)
Beispiel #18
0
# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
#   The first argument is the length of your text, in number of words
#   The 'seedword' argument allows you to feed the bot some words that it
#   should attempt to use to start its text. It's nothing fancy: the bot will
#   simply try the first, and move on to the next if he can't find something
#   that works.

# Print your text to the console

while True:
    try:
        tweet = tweetbot.generate_text(25, seedword=None)
        logger.debug('tweetbot says: ' + tweet)
        api.update_status(tweet)
        logger.debug("Sleeping for " + str(SLEEPING))
        time.sleep(SLEEPING)
        logger.debug("Finished sleeping")
    except tweepy.TweepError as e:
        logger.debug("Teweepy Error " + e.response.text)
        pass

# # # # # #
# # TWITTER

# # The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# # for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter
Beispiel #19
0
    access_token = ""  # f_read.split(" ")[2][0:-1]
    access_token_secret = ""
    cons_key = ""
    cons_secret = ""

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, 'ElonMuskTxt.txt')
# Make your bot read the book!
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['space', 'Tesla'])
print("tweetbot says:")
print(my_first_text)

tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)

from time import sleep
while True:
    tweetbot.twitter_tweeting_start(days=0,
                                    hours=0,
                                    minutes=30,
                                    keywords=[
                                        'SpaceX', 'Tesla', 'Mars', 'Solar',
                                        'Do more', '120 hour work week',
                                        'I am not an alien', 'launch'
Beispiel #20
0
import os
import time
from markovbot import MarkovBot

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, 'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)

my_first_text = tweetbot.generate_text()
print("tweetbot says:")
print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = ""
# Consumer Secret (API Secret)
cons_secret = ""
# Access Token
access_token = ""
# Access Token Secret
access_token_secret = ""

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'data_amazon_one_star.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'failed', u'crap'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))

# # # # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# ALL YOUR SECRET STUFF!
# Make sure to replace the ''s below with your own values, or try to find
# a more secure way of dealing with your keys and access tokens. Be warned
# that it is NOT SAFE to put your keys and tokens in a plain-text script!
Beispiel #22
0
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25,
                                       seedword=[u'dream', u'psychoanalysis'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))

# # # # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# ALL YOUR SECRET STUFF!
# Make sure to replace the ''s below with your own values, or try to find
# a more secure way of dealing with your keys and access tokens. Be warned
# that it is NOT SAFE to put your keys and tokens in a plain-text script!
# Construct the path to the book
book = os.path.join(dirname, u'texto_ejemplo.txt')
# Make your bot read the book!
tweetbot.read(book)


# # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'ella', u'Alicia'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))

 	
# # #
# TWITTER

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter

# Credentials

with open(text_filename, 'r') as f:
	twitter_credentials = json.load(f)