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

require 'trollop'

USAGE = %Q{
get_tweets: Retrieve tweets for a given Twitter screen_name.

Usage:
  ruby get_tweets.rb <options> <WOEID>

  <WOEID>: A Where On Earth ID (http://developer.yahoo.com/geo/geoplanet/)

The following options are supported:
}

def parse_command_line

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

  opts = Trollop::options do
    version "get_trends 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 file"
  end

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

if __FILE__ == $0

  STDOUT.sync = true

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

  args     = { params: params, data: data }

  twitter = TrendsPlace.new(args)

  puts "Getting the current trends for WOEID: #{input[:id]}"

  File.open('trends.json', 'w') do |f|
    twitter.collect do |trends|
      trends.each do |trend|
        f.puts "#{trend.to_json}\n"<commit_msg>Display updates<commit_after>require_relative '../requests/TrendsPlace'

require 'trollop'

USAGE = %Q{
get_trends: Retrieve trending terms for a given Where On Earth ID.

Usage:
  ruby get_tweets.rb <options> <WOEID>

  <WOEID>: A Where On Earth ID (http://developer.yahoo.com/geo/geoplanet/)

The following options are supported:
}

def parse_command_line

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

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

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

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

if __FILE__ == $0

  STDOUT.sync = true

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

  args     = { params: params, data: data }

  twitter = TrendsPlace.new(args)

  puts "Getting the current trends for WOEID: #{input[:id]}"

  File.open('trends.json', 'w') do |f|
    twitter.collect do |trends|
      trends.each do |trend|
        f.puts "#{trend.to_json}\n"
{'fraction_non_alphanumeric': 0.1306326809285389, 'fraction_numerical': 0.007282658170232135, 'mean_word_length': 3.4404040404040406, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '6093572', 'n_tokens_mistral': 841, 'n_tokens_neox': 782, 'n_words': 227}