<commit_before>require "twitter"
require "yaml"
require "net/http"
require 'json'
require 'open-uri'
require 'dotenv'

require_relative 'string_function'
Dotenv.load


url = 'http://adopt-a-pet-denver.herokuapp.com/api'
response =  Net::HTTP.get_response(URI.parse(url))

# get json
# parson json

client = Twitter::REST::Client.new do |config|
	config.consumer_key = ENV.fetch('consumer_key')
	config.consumer_secret = ENV.fetch('consumer_secret')
	config.access_token = ENV.fetch('access_token')
	config.access_token_secret = ENV.fetch('access_token_secret')
end

#parse greetings json
greetings = JSON.parse( IO.read("greetings.json") )

#grab a random greeting from the list
randomgreeting = greetings[rand(greetings.length)]

#parse the json into a hash
animaldata = JSON.parse(response.body);

#remove this after we add it to the API
animaldata['link'] = "http://www.petharbor.com/pet.asp?uaid=DNVR." + animaldata['id']

#building the tweet sentence
mytweet = randomgreeting + " " + animaldata['name'].my_titleize + ". " + animaldata['desc'].strip_html.slice(0..65) + "... " + animaldata['link']
mytweet.remove_double_whitespace

#post the tweet
File.open('image.png', 'wb') do |file|
	file << open(animaldata['pic']).read
	#post the tweet
	client.update_with_media(mytweet, File.open(file))
end<commit_msg>improved the random greeting part<commit_after>require "twitter"
require "yaml"
require "net/http"
require 'json'
require 'open-uri'
require 'dotenv'

require_relative 'string_function'
Dotenv.load


url = 'http://adopt-a-pet-denver.herokuapp.com/api'
response =  Net::HTTP.get_response(URI.parse(url))

# get json
# parson json

client = Twitter::REST::Client.new do |config|
	config.consumer_key = ENV.fetch('consumer_key')
	config.consumer_secret = ENV.fetch('consumer_secret')
	config.access_token = ENV.fetch('access_token')
	config.access_token_secret = ENV.fetch('access_token_secret')
end

#parse greetings json
greetings = JSON.parse( IO.read("greetings.json") )

#grab a random greeting from the list
randomgreeting = greetings.sample

#parse the json into a hash
animaldata = JSON.parse(response.body);

#remove this after we add it to the API
animaldata['link'] = "http://www.petharbor.com/pet.asp?uaid=DNVR." + animaldata['id']

#building the tweet sentence
mytweet = randomgreeting + " " + animaldata['name'].my_titleize + ". " + animaldata['desc'].strip_html.slice(0..65) + "... " + animaldata['link']
mytweet.remove_double_whitespace

#post the tweet
File.open('image.png', 'wb') do |file|
	file << open(animaldata['pic']).read
	#post the tweet
	#client.update_with_media(mytweet, File.open(file))
	puts randomgreeting
end
{'fraction_non_alphanumeric': 0.14522821576763487, 'fraction_numerical': 0.002263296869105998, 'mean_word_length': 5.730964467005077, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '571719', 'n_tokens_mistral': 949, 'n_tokens_neox': 915, 'n_words': 197}