parrot

Read Twitter’s API tokens.

import configparser

config = configparser.ConfigParser()
config.read("../../../../python/python-experiments/twitter.tokens")

api_key = config["secrets"]["api_key"]
api_secret = config["secrets"]["api_secret"]
consumer_token = config["secrets"]["consumer_token"]
consumer_secret = config["secrets"]["consumer_secret"]

Build the API object.

import tweepy

auth = tweepy.OAuthHandler(api_key, api_secret)
auth.set_access_token(consumer_token, consumer_secret)

api = tweepy.API(auth)

Get my own tweets.

public_tweets = api.user_timeline(id="ruimvieira", count=1000)
for tweet in public_tweets[:10]:
    print(tweet.text)
@nmcl From experience: opening a can of tuna.
Part 2 https://t.co/VlPRvFoktJ
R. Sikoryak’s “Good ol’ Gregor Brown” - Franz Kafka meets Charlie Brown. https://t.co/eawp7Ejjqm
Rust memory container cheat-sheet https://t.co/VcDsKGtCaE
Stumbled into someone's peculiar hobby: turning Genesis album covers into vintage CS/computing book covers. https://t.co/PT25wuNsGH
@dumpsternaut @mycoliza I'm trying to be neutral and understand why this is a bad idea.

The discussion seems to be… https://t.co/IKR10se38U
@dumpsternaut @mycoliza Yes, but if you don't provide much info, it will just load whatever is available under that… https://t.co/C5Rshhgbyv
@dumpsternaut @mycoliza Only if you specify the path. If you just pass the DLL name, it seems to work like describe… https://t.co/kBhpnffkvD
@mycoliza So just like LoadLibrary on Windows?
RT @PaulJCormier: .@RedHat stands in solidarity with the Black community - our colleagues, customers, partners and neighbors - and all who…

Split in sentences.

text = []

for tweet in public_tweets:
    text.extend(tweet.text.split("\n"))

Build a Markov chain with punctuated sentences (better results)

import markovify

text_model = markovify.Text(". ".join(text))

Generate 20 new tweets.

for i in range(20):
    tweet = text_model.make_sentence()
    if tweet:
        print(f"- \t {tweet}")
- 	 Looking forward to speak about streaming recommendation engines at @berlinbuzzwords, June 2018.… https://t.co/4OxGcjtas0. https://t.co/6uP8MjSBfl.
- 	 My hotel room has a record collection and Pink Floyd’s 1967 “Interstellar Overdri… https://t.co/e5DQX89R1T.
- 	 . The discussion seems to work like describe… https://t.co/kBhpnffkvD.
- 	 If you just pass the DLL name, it seems to have disappeared from “prefere… https://t.co/sbXxUXThy0.
- 	 A type of fairground distorting mirror where you don't provide much info, it will just load whatever is available under that… https://t.co/C5Rshhgbyv.
- 	 I have great memories of the cupboard that you completely forgot about..
- 	 Jonh Wendell talking about MR from a user perspective at the Flying Hippo. https://t.co/NoSfUaAIl5.
- 	 @derekwalmsley This is excellent..
- 	 RT @cheshireminima: @pssalgado is now talking about Istio on #Kubernetes ⁦@devconf_us⁩ #defineFUTURE https://t.co/yIFNxlrVNL.
- 	 Weekend contrite lessons: setting up multiple accounts on Twitter and building your own social media data is hilarious.
- 	 If you just pass the DLL name, it seems to permeate an awful lot of online comment sections. https://t.co/QP6T7j4gtZ.
- 	 Jonh Wendell talking about MR from a user perspective at the Flying Hippo. https://t.co/NoSfUaAIl5.
- 	 See https://t.co/q4idrQRyNq for more, or visit https://t…. @eliistender10 I would be delighted, that would happen..