<commit_before>require 'rubygems'
require 'open-uri'
require 'json'

module URI
  def short(uri)
    uri = URI.escape("http://j.mp/?s=&keyword=&url=#{target}")
    Nokogiri::HTML(open(uri).read).at('#shortened-url')['value']
  end

  module_function :short
end<commit_msg>fixed j.mp method<commit_after>require 'rubygems'
require 'open-uri'
require 'json'

module URI
  SHORT_URI_API_LOGIN = ENV['SHORT_URI_API_LOGIN']
  SHORT_URI_API_TOKEN = ENV['SHORT_URI_API_TOKEN']

  def self.short(uri)
    return uri if SHORT_URI_API_LOGIN == nil
    begin
      query  = "http://api.j.mp/shorten?version=2.0.1&longUrl=#{uri.gsub('&', '%26')}&login=#{SHORT_URI_API_LOGIN}&apiKey=#{SHORT_URI_API_TOKEN}"
      result = JSON.parse(open(query).read)

      result.first[1].first[1]['shortUrl']
    rescue Exception => e
      URI.encode(uri)
    end
  end
end
{'fraction_non_alphanumeric': 0.1617473435655254, 'fraction_numerical': 0.008264462809917356, 'mean_word_length': 4.6158940397351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7266349', 'n_tokens_mistral': 332, 'n_tokens_neox': 324, 'n_words': 51}