<commit_before><commit_msg>Add a simple Sinatra webserver for previewing<commit_after>#!/usr/bin/env ruby

require 'sinatra'

# Compile CoffeeScript to JavaScript if a .coffee file is found,
# otherwise just serve up the .js file.
get %r{/(.*)\.js} do |basename|
  content_type 'application/javascript'
  coffee = "#{basename}.coffee"
  if File.exist?(coffee)
    print "Compiling #{coffee}...\n"
    response = `coffee -c -p #{coffee}`
    raise 'Compile error' if $?.exitstatus != 0
    response
  else
    send_file "#{basename}.js"
  end
end

get %r{/(.*)} do |filename|
  send_file filename
end
{'fraction_non_alphanumeric': 0.1419031719532554, 'fraction_numerical': 0.001669449081803005, 'mean_word_length': 3.7244094488188977, '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': '5024704', 'n_tokens_mistral': 216, 'n_tokens_neox': 205, 'n_words': 64}