<commit_before>require 'nokogiri'
require 'open-uri'

module Fletcher
  # This class is responsible for fetching and parsing data.
  class Data
    # Get read url and get data object
    def self.read(url, options = {})
      response = open(url, "User-Agent" => Fletcher::USER_AGENT)
      doc = ::Nokogiri::HTML(response.read)
      
      # Save contents of URL/Remote File for debugging
      # response.rewind
      # last_response_file = File.expand_path(File.join("..", "..", "last_response"), File.dirname(__FILE__))        
      # File.new(last_response_file, "w+").write(response.read)
      return doc
    end 
  end
end<commit_msg>adding user_agent as parameter to the data.read method<commit_after>require 'nokogiri'
require 'open-uri'

module Fletcher
  # This class is responsible for fetching and parsing data.
  class Data
    # Get read url and get data object
    def self.read(url, agent = nil)
      user_agent = agent.blank? ? Fletcher::USER_AGENT : agent
      response = open(url, "User-Agent" => user_agent)
      doc = ::Nokogiri::HTML(response.read)

      # Save contents of URL/Remote File for debugging
      # response.rewind
      # last_response_file = File.expand_path(File.join("..", "..", "last_response"), File.dirname(__FILE__))
      # File.new(last_response_file, "w+").write(response.read)
      return doc
    end
  end
end
{'fraction_non_alphanumeric': 0.11566617862371889, 'fraction_numerical': 0.0, 'mean_word_length': 3.2191358024691357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3668917', 'n_tokens_mistral': 432, 'n_tokens_neox': 414, 'n_words': 115}