Created
June 6, 2017 18:29
-
-
Save mcoms/056c080c8771d221e1be1ddc743f95bd to your computer and use it in GitHub Desktop.
Train a Markov chain on your tweets so you don't have to think of tweets anymore
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
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'marky_markov', '~> 0.3.5' | |
gem 'twitter', '~> 6.1.0' |
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
require 'bundler' | |
Bundler.require | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = '...' | |
config.consumer_secret = '...' | |
config.access_token = '...' | |
config.access_token_secret = '...' | |
end | |
tweets = client.user_timeline(client.user.id, count: 200, trim_user: true, exclude_replies: true, contributor_details: false, include_rts: false) | |
markov = MarkyMarkov::Dictionary.new('twitter_dictionary') | |
tweets.each {|t| markov.parse_string t.full_text } | |
markov.save_dictionary! | |
puts markov.generate_n_words 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment