Beispiel #1
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)
import os

from markovbot import MarkovBot

# # # # #
# INITIALISE

# 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, 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))
Beispiel #3
0
from markovbot import MarkovBot


# # # # #
# INITIALISE

# 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, 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))
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 #5
0
fThree = (fTwo.replace("SCENE", " "))
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')
Beispiel #6
0
    with open('%s_tweets.txt' % screen_name, 'wb') as f:
        for tweet in alltweets:
            f.write(tweet.text.encode("utf-8") + ' '.encode("utf-8"))

    pass


get_all_tweets("kanyewest")
kanyebot = MarkovBot()

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

kanyebot.twitter_login(consumer_key, consumer_secret, access_key,
                       access_secret)

# Set some parameters for your bot
targetstring = 'KanyeToTheBot'
keywords = ['kim', 'pablo', 'wavy', 'bill', 'cosby']
prefix = None
suffix = '#KanyeToTheBot'
maxconvdepth = None

# Start periodically tweeting
kanyebot.twitter_tweeting_start(days=0,
                                hours=0,
                                minutes=15,
Beispiel #7
0
# import config # contains the API keys and access tokens
import twitter
import os
import time

from markovbot import MarkovBot

# Initialise the MarkovBot instance
tweetbot = MarkovBot()

# Get the seinfeld transcripts and read
dirname = os.path.dirname(os.path.abspath(__file__))
textFile = os.path.join(dirname, 'seinfelf.txt')
tweetbot.read(textFile)

# Text Generations

# Log in to Twitter
consumer_key = os.environ.get('cons_key')
consumer_key_secret = os.environ.get('cons_secret')
access_token = os.environ.get('access_token')
access_token_secret = os.environ.get('access_token_secret')
tweetbot.twitter_login(consumer_key, consumer_key_secret, access_token,
                       access_token_secret)

# Start periodically tweeting
while True:
    minutesToWait = 120
    secondsToWait = 60 * minutesToWait
    tweetbot.twitter_tweeting_start(days=0,
                                    hours=0,
Beispiel #8
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')
# -*- coding: utf-8 -*-

import os
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 ]'
Beispiel #10
0
def getBot(filePath):
    tweetbot = MarkovBot()
    tweetbot.read(filePath)
    return tweetbot