<commit_before>
local utils = require('utils')
local uv = require('uv')
local stdin
if uv.guess_handle(0) ~= "TTY" or
   uv.guess_handle(1) ~= "TTY" then
  error "stdio must be a tty"
end
local stdin = uv.new_tty(0, true)
local stdout = uv.new_tty(1)

local c = utils.color

local function gatherResults(success, ...)
  local n = select('#', ...)
  return success, { n = n, ... }
end

local function printResults(results)
  for i = 1, results.n do
    results[i] = utils.dump(results[i])
  end
  print(table.concat(results, '\t'))
end

local buffer = ''

local function evaluateLine(line)
  if line == "<3\n" then
    print("I " .. c("Bred") .. "♥" .. c() .. " you too!")
    return '>'
  end
  local chunk  = buffer .. line
  local f, err = loadstring('return ' .. chunk, 'REPL') -- first we prefix return<commit_msg>Use uv for all I/O in repl example<commit_after>
local utils = require('utils')
local uv = require('uv')
local stdin
if uv.guess_handle(0) ~= "TTY" or
   uv.guess_handle(1) ~= "TTY" then
  error "stdio must be a tty"
end
local stdin = uv.new_tty(0, true)
local stdout = uv.new_tty(1)
local print = function(...)
  uv.write(stdout, table.concat({...}, "\t") .. "\n")
end

local c = utils.color

local function gatherResults(success, ...)
  local n = select('#', ...)
  return success, { n = n, ... }
end

local function printResults(results)
  for i = 1, results.n do
    results[i] = utils.dump(results[i])
  end
  print(table.concat(results, '\t'))
end

local buffer = ''

local function evaluateLine(line)
  if line == "<3\n" then
    print("I " .. c("Bred") .. "♥" .. c() .. " you too!")
    return '>'
  end
  local chunk  = buffer .. line
  local f, err = loadstring('return ' .. chunk, 'REPL') -- first we prefix return
{'fraction_non_alphanumeric': 0.17670682730923695, 'fraction_numerical': 0.0068846815834767644, 'mean_word_length': 3.142517814726841, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2594328', 'n_tokens_mistral': 638, 'n_tokens_neox': 629, 'n_words': 192}