<commit_before>require 'parallel'

module Marmalade
  class Puzzle
    attr_accessor :reader

    def initialize(file_reader, options = {})
      @options = options.dup
      @debug = (@options.delete(:debug) == true)
      self.reader = file_reader
    end

    def read_num_cases
      read :num_cases, :type => :int
    end

    def read(assignments, options = {})
      assigns = reader.read(assignments, options)
      assigns.each do |k, v|
        # Set an ivar on both the puzzle and the test case so we can support using them in
        # subsequent calls to 'read' in the same block evaluation.<commit_msg>Set the parallel option if a process count is given<commit_after>require 'parallel'

module Marmalade
  class Puzzle
    attr_accessor :reader

    def initialize(file_reader, options = {})
      self.reader = file_reader
      @options = options.dup
      @debug = (@options[:debug] == true)
      if @options[:processes].to_i > 1 && !@options[:parallel]
        @options[:parallel] = true
      end
    end

    def read_num_cases
      read :num_cases, :type => :int
    end

    def read(assignments, options = {})
      assigns = reader.read(assignments, options)
      assigns.each do |k, v|
        # Set an ivar on both the puzzle and the test case so we can support using them in
        # subsequent calls to 'read' in the same block evaluation.
{'fraction_non_alphanumeric': 0.09117432530999271, 'fraction_numerical': 0.0007293946024799417, 'mean_word_length': 2.769230769230769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5865129', 'n_tokens_mistral': 401, 'n_tokens_neox': 397, 'n_words': 141}