<commit_before>require 'cgi'
require 'counting_step'
require 'step_collection'
class StepGroup
  attr_reader :id, :regex, :total_usage

  def initialize(step)
    @id = step.id
    @regex = step.regex
    @total_usage = 0
    @step_collection = StepCollection.new
  end

  def step_collection
    @step_collection.sort
  end

  def add_step(step)
    @step_collection << step
  end

  def update_use_count
    @total_usage = 0
    @step_collection.each do |step|
      @total_usage += step.count
    end
    @total_usage
  end

  def use_count
    @total_usage || 0
  end

  def group_graph
    base = "https://chart.googleapis.com/chart?cht=gv:dot&chl=graph{"
    base += "a [label=\"#{CGI.escape(CGI.escapeHTML(@regex.inspect.to_s))}\"];"

    in_steps[0..10].each do |id,in_step|

      next if in_step.regex.nil?
      base += "a--\"#{CGI.escape(CGI.escapeHTML(in_step.regex.inspect.to_s))}\" [weight=#{in_step.count}];"
      #a [label=\"#{grouping.in_steps[0][:step].regex.inspect}\"]; a--b [penwidth=3,weight=2];b--d}"
    end
    base += "}"
    base
  end

end
<commit_msg>fix dot graph generation again<commit_after>require 'cgi'
require 'counting_step'
require 'step_collection'
class StepGroup
  attr_reader :id, :regex, :total_usage

  def initialize(step)
    @id = step.id
    @regex = step.regex
    @total_usage = 0
    @step_collection = StepCollection.new
  end

  def step_collection
    @step_collection.sort
  end

  def add_step(step)
    @step_collection << step
  end

  def update_use_count
    @total_usage = 0
    @step_collection.each do |step|
      @total_usage += step.count
    end
    @total_usage
  end

  def use_count
    @total_usage || 0
  end

  def group_graph
    base = "https://chart.googleapis.com/chart?cht=gv:dot&chl=graph{"
    base += "a [label=\"#{CGI.escape(CGI.escapeHTML(@regex.inspect.to_s))}\"];"

    step_collection[0..10].each do |step|

      next if step.regex.nil?
      base += "a--\"#{CGI.escape(CGI.escapeHTML(step.regex.inspect.to_s))}\" [weight=#{step.count}];"
      #a [label=\"#{grouping.in_steps[0][:step].regex.inspect}\"]; a--b [penwidth=3,weight=2];b--d}"
    end
    base += "}"
    base
  end

end

{'fraction_non_alphanumeric': 0.1514035895075932, 'fraction_numerical': 0.008283479061205707, 'mean_word_length': 3.2213592233009707, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4356027', 'n_tokens_mistral': 825, 'n_tokens_neox': 802, 'n_words': 152}