<commit_before>require_relative '../requests/Favorites'

require 'trollop'

USAGE = %Q{
get_favorites: Gets all favorited tweets by the given user.

Usage:
  ruby get_favorites.rb <options> <screen_name>

  <screen_name>: A Twitter screen_name.

The following options are supported:
}

def parse_command_line

  options = {type: :string, required: true}

  opts = Trollop::options do
    version "get_favorites 0.1 (c) 2015 <NAME>"
    banner USAGE
    opt :props, "OAuth Properties File", options
  end

  unless File.exist?(opts[:props])
    Trollop::die :props, "must point to a valid oauth properties file"
  end

  opts[:screen_name] = ARGV[0]
  opts
end

if __FILE__ == $0

  STDOUT.sync = true

  input  = parse_command_line
  params = { screen_name: input[:screen_name] }
  data   = { props: input[:props] }

  args     = { params: params, data: data }

  twitter = Favorites.new(args)

  puts "Collecting the favorite tweets of '#{input[:screen_name]}'"

  File.open('favorite_tweets_for_' + input[:screen_name] + '.json', 'w') do |f|
    twitter.collect do |favorites|
      favorites.each do |favorite|
        f.puts "#{favorite.to_json}\n"
      end
    end
  end

  puts "DONE."

end
<commit_msg>updating usage<commit_after>require_relative '../requests/Favorites'

require 'trollop'

USAGE = %Q{
get_favorites: Gets up to 100 favorited tweets by the given user.

Usage:
  ruby get_favorites.rb <options> <screen_name>

  <screen_name>: A Twitter screen_name.

The following options are supported:
}

def parse_command_line

  options = {type: :string, required: true}

  opts = Trollop::options do
    version "get_favorites 0.1 (c) 2015 <NAME>"
    banner USAGE
    opt :props, "OAuth Properties File", options
  end

  unless File.exist?(opts[:props])
    Trollop::die :props, "must point to a valid oauth properties file"
  end

  opts[:screen_name] = ARGV[0]
  opts
end

if __FILE__ == $0

  STDOUT.sync = true

  input  = parse_command_line
  params = { screen_name: input[:screen_name] }
  data   = { props: input[:props] }

  args     = { params: params, data: data }

  twitter = Favorites.new(args)

  puts "Collecting the favorite tweets of '#{input[:screen_name]}'"

  File.open('favorite_tweets_for_' + input[:screen_name] + '.json', 'w') do |f|
    twitter.collect do |favorites|
      favorites.each do |favorite|
        f.puts "#{favorite.to_json}\n"
      end
    end
  end

  puts "DONE."

end

{'fraction_non_alphanumeric': 0.11866501854140915, 'fraction_numerical': 0.007828594973217964, 'mean_word_length': 3.546816479400749, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2185803', 'n_tokens_mistral': 888, 'n_tokens_neox': 848, 'n_words': 239}