<commit_before>#!/usr/bin/env ruby

require "pp"

folder = "grabbers"
shows = []

# go through each grabber script in the grabbers folder and grab the shows
Dir.foreach(folder) do |file|
  next unless file =~ /[[:word:]]/
  # dynamically load and run the grab script to get the shows from the website
  mod = Module.new
  load "#{folder}/#{file}"
  mod.const_set("Grabber", Grabber)
  Object.send(:remove_const, :Grabber)
  shows << mod::Grabber.shows
end

PP.pp(shows)<commit_msg>Output to json instead of ruby object.  Run each grabber in a thread.<commit_after>#!/usr/bin/env ruby

require "thread"
require "json"

FOLDER = "grabbers"
threads = []
shows = []

# go through each grabber script in the grabbers folder and grab the shows
Dir.foreach(FOLDER) do |file|
  next unless file =~ /[[:word:]]/
  # Start a thread for each grabber
  threads << Thread.new {
    # dynamically load and run the grab script to get the shows from the website
    mod = Module.new
    load "#{FOLDER}/#{file}"
    mod.const_set("Grabber", Grabber)
    Object.send(:remove_const, :Grabber)
    shows.concat(mod::Grabber.shows)
  }
  # restrict to only running 5 at a time
  if threads.size >= 5
    threads.each { |thread| thread.join }
    threads = []
  end
end

# wait until last of the threads are done
threads.each { |thread| thread.join }

print(shows.to_json)
{'fraction_non_alphanumeric': 0.11991117690599556, 'fraction_numerical': 0.0014803849000740192, 'mean_word_length': 3.710801393728223, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '2686104', 'n_tokens_mistral': 461, 'n_tokens_neox': 454, 'n_words': 154}