<commit_before># require rubygems and sinatra so you can run this application locally with ruby app.rb
require 'rubygems'
require 'sinatra'
require 'mongo'
require 'json'

DB = Mongo::Connection.new.db("quest", :pool_size => 5, :timeout => 5)
#auth = DB.authenticate('admin', '<PASSWORD>')


  get '/' do 
    DB.collection(params[:thing]).find.to_a.map{|t| from_bson_id(t)}.to_json
    erb :index
  end

  get '/api/:thing' do
    DB.collection(params[:thing]).find.to_a.to_json
  end

  get '/quiz' do
    JSON.parse(File.read(DATA_FILE)).to_json
  end

  get '/reformat' do
    response = JSON.parse(File.read(DATA_FILE))

    File.open(DATA_FILE, 'w'){|f| f.write(response.to_json)}
  end

  post '/quiz' do
    data = JSON.parse(File.read(DATA_FILE))

    nextId = data.map{ |item|
      item[:id]
    }.max.next

  end

def to_bson_id(id) BSON::ObjectId.from_string(id) end
def from_bson_id(obj) obj.merge({'_id' => obj['_id'].to_s}) end<commit_msg>Cleaned app<commit_after># require rubygems and sinatra so you can run this application locally with ruby app.rb
require 'rubygems'
require 'sinatra'
require 'mongo'
require 'json'

DB = Mongo::Connection.new.db("quest", :pool_size => 5, :timeout => 5)
#auth = DB.authenticate('admin', '<PASSWORD>')


  get '/' do 
    DB.collection(params[:thing]).find.to_a.map{|t| from_bson_id(t)}.to_json
    erb :index
  end

  get '/api/:thing' do
    DB.collection(params[:thing]).find.to_a.to_json
  end

def to_bson_id(id) BSON::ObjectId.from_string(id) end
def from_bson_id(obj) obj.merge({'_id' => obj['_id'].to_s}) end
{'fraction_non_alphanumeric': 0.16124920331421289, 'fraction_numerical': 0.0025493945188017845, 'mean_word_length': 4.233333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4830355', 'n_tokens_mistral': 617, 'n_tokens_neox': 591, 'n_words': 131}