Created
October 4, 2016 03:37
-
-
Save edyesed/5d69ccbd7c3c43e30677d7055f22584d to your computer and use it in GitHub Desktop.
so you want to do something with a markov bot and tweeter....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
import twitter | |
from pymarkovchain import MarkovChain | |
from pprint import pprint | |
TW_CONSUMER_KEY='xxx' | |
TW_CONSUMER_SECRET='yyy' | |
TW_ACCESS_TOKEN='aaa' | |
TW_TOKEN_SECRET='bbb' | |
if __name__ == "__main__": | |
api = twitter.Api(consumer_key=TW_CONSUMER_KEY, | |
consumer_secret=TW_CONSUMER_SECRET, | |
access_token_key=TW_ACCESS_TOKEN, | |
access_token_secret=TW_TOKEN_SECRET) | |
tweets = api.GetUserTimeline(screen_name="RikerGoogling",count=200) | |
#pprint(tweets) | |
# or someplace. Expect a scary error if this file is E_NOENT | |
# then the library makes the file. /shrug | |
mc = MarkovChain("/var/tmp/markov.riker") | |
# don't worry about a bunch of None | |
[ mc.generateDatabase(t.__dict__['text']) for t in tweets ] | |
print mc.generateStringWithSeed("rudy") | |
print mc.generateStringWithSeed("rudy") | |
print mc.generateStringWithSeed("picard") | |
print mc.generateStringWithSeed("picard") | |
print mc.generateStringWithSeed("planet") | |
print mc.generateStringWithSeed("planet") | |
print mc.generateStringWithSeed("planet") | |
print mc.generateStringWithSeed("planet") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment