<commit_before>#!/usr/bin/ruby -w

require 'nokogiri'
require 'open-uri'
require 'uri'
require 'byebug'
require 'getoptlong'
#require 'rubygems'
require 'json'

require_relative './config.rb'

if ARGV[1].nil? then
    $stderr.puts "Need:\n- the price of the home\n- The address"
    puts ARGV
    exit 1
end

amount=ARGV[0].gsub(/[\s,]/ ,"")

url="http://ottawa.ca/cgi-bin/tax/tax.pl?year=24&property_type=110&tr=1&f=8&sw=5&assessment=#{amount}&submit=Submit+Query&lang=en"

puts url

doc = Nokogiri::HTML(open(url))

taxes = doc.xpath("//tr[@class='taxResults']//td")[1].text.gsub(/[\s,]|\$/ ,"").to_f


gmapsUrlBase="https://maps.googleapis.com/maps/api/distancematrix/json?"

$destinations.each { |dest,coords|
    url = gmapsUrlBase + "origins=" + ARGV[1].tr(' ', '+') + "&destinations=" + coords.tr(' ', '+') + "&mode=transit" + "&key=" + $apiKey
    resultsHash =  JSON.parse(open(url).read)

    debugger
    commuteTime = resultsHash['rows'][0]['elements'][0]['duration']['text']

    puts "#{dest}: #{commuteTime}"

    #debugger
}
<commit_msg>added commute time to specified destinations<commit_after>#!/usr/bin/ruby -w

require 'nokogiri'
require 'open-uri'
require 'uri'
require 'byebug'
require 'getoptlong'
#require 'rubygems'
require 'json'

require_relative './config.rb'

if ARGV[1].nil? then
    $stderr.puts "Need:\n- the price of the home\n- The address"
    puts ARGV
    exit 1
end

amount=ARGV[0].gsub(/[\s,]/ ,"")

url="http://ottawa.ca/cgi-bin/tax/tax.pl?year=24&property_type=110&tr=1&f=8&sw=5&assessment=#{amount}&submit=Submit+Query&lang=en"

puts url

doc = Nokogiri::HTML(open(url))

taxes = doc.xpath("//tr[@class='taxResults']//td")[1].text.gsub(/[\s,]|\$/ ,"").to_f


gmapsUrlBase="https://maps.googleapis.com/maps/api/distancematrix/json?"

$destinations.each { |dest,coords|

    modeHash = {}

    ['walking', 'bicycling', 'transit'].each { |mode|
        url = gmapsUrlBase + "origins=" + ARGV[1].tr(' ', '+') + "&destinations=" + coords.tr(' ', '+') + "&mode=#{mode}" + "&key=" + $apiKey
        resultsHash =  JSON.parse(open(url).read)


        commuteTime = resultsHash['rows'][0]['elements'][0]['duration']['text']

        modeHash[mode] = commuteTime

        debugger if mode == 'cycling'
    }

    puts "#{dest}: #{modeHash.to_s}"

}

{'fraction_non_alphanumeric': 0.21735319894829097, 'fraction_numerical': 0.013146362839614373, 'mean_word_length': 4.284722222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5332891', 'n_tokens_mistral': 921, 'n_tokens_neox': 882, 'n_words': 144}