<commit_before>class Tritium::Engines::Debug
  class Step::Node < Step
    def search(selector)
      @object.xpath(selector)
    end
    
    def select(selector)
      start = Time.now
      child_nodeset = search(selector)
      
      debug_log("Searching #{object.path} with #{selector} and found #{child_nodeset.size} matches")
      
      @debug[:search_time_cs] = ((Time.now - start) * 10000).to_i
      
      child_nodeset.each_with_index do |child_node, index|
        debug_log("Entering #{selector} match ##{index + 1} at #{child_node.path}")
        @name = child_node.path
        execute_children_on(child_node)
        debug_log("Finishing #{selector} match ##{index + 1} at #{child_node.path}")
      end
      
      debug_log("Closing #{selector}")
    end
    
    def remove
      debug_log("Removing #{object.path}")
      object.remove
    end
    
    def html
      debug_log("Opening the raw text HTML of #{@object.path}")
      @object.inner_html = execute_children_on(@object.inner_html)
    end
    
    def attribute(name)
      attribute_node = @object.attributes[name]
      if attribute_node.nil?
        @object[name] = ""
        attribute_node = @object.attributes[name]<commit_msg>Debug: Better messages for select()<commit_after>class Tritium::Engines::Debug
  class Step::Node < Step
    def search(selector)
      @object.xpath(selector)
    end
    
    def select(selector)
      start = Time.now
      child_nodeset = search(selector)
      
      debug_log("Searching #{object.path} with #{selector} and found #{child_nodeset.size} matches")
      
      @debug[:search_time_cs] = ((Time.now - start) * 10000).to_i
      
      child_nodeset.each_with_index do |child_node, index|
        debug_log("Match ##{index + 1} at #{child_node.path}")
        @name = child_node.path
        execute_children_on(child_node)
      end
    end
    
    def remove
      debug_log("Removing #{object.path}")
      object.remove
    end
    
    def html
      debug_log("Opening the raw text HTML of #{@object.path}")
      @object.inner_html = execute_children_on(@object.inner_html)
    end
    
    def attribute(name)
      attribute_node = @object.attributes[name]
      if attribute_node.nil?
        @object[name] = ""
        attribute_node = @object.attributes[name]
{'fraction_non_alphanumeric': 0.11471861471861472, 'fraction_numerical': 0.005627705627705628, 'mean_word_length': 2.674085850556439, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4709735', 'n_tokens_mistral': 723, 'n_tokens_neox': 717, 'n_words': 150}