<commit_before>#encoding: utf-8
require 'configuration'
require 'model'
require 'erb'
require 'fileutils'

class Renderer
  include FileUtils

  def initialize()
    mkdir_p output_dir
  end

  def output_dir
    File.join(home_dir, 'output')
  end

  def home_dir
    File.join(File.dirname(__FILE__), '..')  
  end
  
  def read_template(template)
    File.read(File.join(home_dir, 'templates', template))
  end

  def render_sessions_with_template(sessions, template)
    erb = ERB.new(read_template(template))
    content = erb.result binding
    if block_given?
      return yield content
    end
    content
  end

  def write(content, file_name='sessions.html')
    File.open(File.join(output_dir, file_name), 'w+') do |file|
      file.write content
    end
  end

  def clear(index)
    index % 3 == 0
  end
end
<commit_msg>puts after writing to file<commit_after>#encoding: utf-8
require 'configuration'
require 'model'
require 'erb'
require 'fileutils'

class Renderer
  include FileUtils

  def initialize()
    mkdir_p output_dir
  end

  def output_dir
    File.join(home_dir, 'output')
  end

  def home_dir
    File.join(File.dirname(__FILE__), '..')  
  end
  
  def read_template(template)
    File.read(File.join(home_dir, 'templates', template))
  end

  def render_sessions_with_template(sessions, template)
    erb = ERB.new(read_template(template))
    content = erb.result binding
    if block_given?
      return yield content
    end
    content
  end

  def write(content, file_name='sessions.html')
    f = File.join(output_dir, file_name)
    File.open(f, 'w+') do |file|
      file.write content
    end
    puts "wrote #{content.length} to #{f}"
  end

  def clear(index)
    index % 3 == 0
  end
end

{'fraction_non_alphanumeric': 0.10161662817551963, 'fraction_numerical': 0.003464203233256351, 'mean_word_length': 3.310945273631841, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5780099', 'n_tokens_mistral': 607, 'n_tokens_neox': 586, 'n_words': 149}