<commit_before>module F1Results
  class Event
    attr_accessor :season, :country, :type, :grand_prix, :results

    def initialize(args)
      args.each { |k,v| send("#{k}=", v) }
      @results = []
    end

    def country
      @country.split(/(\W)/).map(&:capitalize).join
    end

    def qualifying?
      @type == :qualifying
    end

    def race?
      @type == :race
    end

    def to_a
      @results.map(&:to_a)
    end

    def winner
      @results.first.driver
    end

    def loser
      @results.last.driver
    end

    def parse_results_table(table)
      data = table.xpath('//tr[not(position()=1)]').map do |row|
        row.xpath('./td').map do |col|
          col.text.strip
        end
      end

      data.each_with_index do |row, i|
        klass = qualifying? ? QualifyingResult : RaceResult
        result = klass.new(row)
        result.index = i + 1
        @results << result unless result.position.nil?
      end

      self
    end
  end
end
<commit_msg>Clear event results when parsing a table<commit_after>module F1Results
  class Event
    attr_accessor :season, :country, :type, :grand_prix, :results

    def initialize(args)
      args.each { |k,v| send("#{k}=", v) }
      @results = []
    end

    def country
      @country.split(/(\W)/).map(&:capitalize).join
    end

    def qualifying?
      @type == :qualifying
    end

    def race?
      @type == :race
    end

    def to_a
      @results.map(&:to_a)
    end

    def winner
      @results.first.driver
    end

    def loser
      @results.last.driver
    end

    def parse_results_table(table)
      @results = []
      data = table.xpath('//tr[not(position()=1)]').map do |row|
        row.xpath('./td').map do |col|
          col.text.strip
        end
      end

      data.each_with_index do |row, i|
        klass = qualifying? ? QualifyingResult : RaceResult
        result = klass.new(row)
        result.index = i + 1
        @results << result unless result.position.nil?
      end

      self
    end
  end
end

{'fraction_non_alphanumeric': 0.12309207287050714, 'fraction_numerical': 0.0029542097488921715, 'mean_word_length': 1.944927536231884, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6163484', 'n_tokens_mistral': 686, 'n_tokens_neox': 658, 'n_words': 163}