<commit_before>require 'json'

class Schedule
  include Enumerable
  
  def initialize(schedule_file = "./schedule.json")
    schedule = JSON.parse(File.read(schedule_file)) rescue []
    @schedule = schedule.map do |s|
      {
        title: s['title'],
        from: s['from'],
        to: s['to'],
        sound_only: s['sound_only'] || false
      }
    end
  end

  def [](idx)
    @schedule[idx]
  end

  def each &block
    @schedule.each(&block)
  end
end<commit_msg>Load margin value from schedule file<commit_after>require 'json'
require_relative 'config'

class Schedule
  include Enumerable
  
  def initialize(schedule_file = "./schedule.json")
    config = Config.new
    schedule = JSON.parse(File.read(schedule_file)) rescue []
    @schedule = schedule.map do |s|
      {
        title: s['title'],
        from: s['from'],
        to: s['to'],
        sound_only: s['sound_only'] || false,
        margin: s['margin'] || config.margin
      }
    end
  end

  def [](idx)
    @schedule[idx]
  end

  def each &block
    @schedule.each(&block)
  end
end
{'fraction_non_alphanumeric': 0.13751169317118803, 'fraction_numerical': 0.0, 'mean_word_length': 2.6026936026936025, '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': '854868', 'n_tokens_mistral': 347, 'n_tokens_neox': 340, 'n_words': 85}