<commit_before>
def pip_install(egg_name)
  puts ""
  puts " → Installing '#{egg_name}' using 'pip' ..."
  safe_exec("pip", "install proselint", check_args: "-V") do
    puts "\t * Command 'pip' is not available"
    puts "\t * Installing 'pip' using 'easy_install' ..."
    execute_command("sudo easy_install pip", prefix: "easy_install: ")
  end
end

def bundle_install
  puts ""
  puts " → Installing gems using bundler ..."
  safe_exec("bundle", "install") do
    puts "\t * Command 'bundle' is not available"
    puts "\t * Installing 'bundle' using 'gem install' ..."
    execute_command("gem install bundler", prefix: "gem: ")
  end
end

def safe_exec(command, command_args, check_args: "-v")
  execute_command = ->() { pretty_print(`#{command} #{command_args}`, "#{command}: ") }
  if system("#{command} #{check_args} > /dev/null 2>&1")
    execute_command.call()
  elsif block_given?
    if yield
      execute_command.call()
    else
      puts "Error: '#{command}' could not be installed."
      exit 1
    end
  else
    puts "Error: command '#{command}' is not available"
    exit 1
  end
end

def execute_command(command, prefix: "")
  output = `#{command}`
  exit_code = $?.exitstatus
  pretty_print(output, prefix: prefix)
  exit_code == 0
end

def pretty_print(message, prefix: "")<commit_msg>Fix error when calling pretty_print<commit_after>
def pip_install(egg_name)
  puts ""
  puts " → Installing '#{egg_name}' using 'pip' ..."
  safe_exec("pip", "install proselint", check_args: "-V") do
    puts "\t * Command 'pip' is not available"
    puts "\t * Installing 'pip' using 'easy_install' ..."
    execute_command("sudo easy_install pip", prefix: "easy_install: ")
  end
end

def bundle_install
  puts ""
  puts " → Installing gems using bundler ..."
  safe_exec("bundle", "install") do
    puts "\t * Command 'bundle' is not available"
    puts "\t * Installing 'bundle' using 'gem install' ..."
    execute_command("gem install bundler", prefix: "gem: ")
  end
end

def safe_exec(command, command_args, check_args: "-v")
  execute_command = ->() { pretty_print(`#{command} #{command_args}`, prefix: "#{command}: ") }
  if system("#{command} #{check_args} > /dev/null 2>&1")
    execute_command.call()
  elsif block_given?
    if yield
      execute_command.call()
    else
      puts "Error: '#{command}' could not be installed."
      exit 1
    end
  else
    puts "Error: command '#{command}' is not available"
    exit 1
  end
end

def execute_command(command, prefix: "")
  output = `#{command}`
  exit_code = $?.exitstatus
  pretty_print(output, prefix: prefix)
  exit_code == 0
end

def pretty_print(message, prefix: "")
{'fraction_non_alphanumeric': 0.14981132075471698, 'fraction_numerical': 0.0037735849056603774, 'mean_word_length': 3.6672535211267605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5737088', 'n_tokens_mistral': 885, 'n_tokens_neox': 872, 'n_words': 261}