<commit_before>require 'rubygems'
require 'bud'
require 'time'

# TODO: change this so that the interface is just input :set_alarm with a timeout and output :alarm with a timeout
# all set alarm would do is delete the current alarm and start another one

module ProgressTimerProtocol
  state do
    interface :input, :set_alarm, [:time_out]
    interface :output, :alarm, [:time_out]
  end
end

module ProgressTimer
  include ProgressTimerProtocol

  state do
    table :timer_state, [] => [:start_tm, :time_out]
    table :buffer, set_alarm.schema
    periodic :timer, 0.01
  end

  bloom :timer_logic do
    buffer <= set_alarm
    temp :cyc <= (buffer * timer)
    stdio <~ cyc.inspected
    timer_state <+- cyc.map {|s, t| [t.val.to_f, s.time_out]}
    buffer <- cyc.map{|s, t| s}

    alarm <= (timer_state * timer).map do |s, t|
      if t.val.to_f - s.start_tm > s.time_out
        [s.time_out]
      end
    end

    timer_state <- (timer_state * alarm).lefts
  end
end<commit_msg>key errors<commit_after>require 'rubygems'
require 'bud'
require 'time'

# TODO: change this so that the interface is just input :set_alarm with a timeout and output :alarm with a timeout
# all set alarm would do is delete the current alarm and start another one

module ProgressTimerProtocol
  state do
    interface :input, :set_alarm, [:time_out]
    interface :output, :alarm, [:time_out]
  end
end

module ProgressTimer
  include ProgressTimerProtocol

  state do
    table :timer_state, [:start_tm, :time_out]
    table :buffer, set_alarm.schema
    periodic :timer, 0.01
  end

  bloom :timer_logic do
    buffer <= set_alarm
    temp :cyc <= (buffer * timer)
    stdio <~ cyc.inspected
    timer_state <+- cyc.map {|s, t| [t.val.to_f, s.time_out]}
    buffer <- cyc.map{|s, t| s}

    alarm <= (timer_state * timer).map do |s, t|
      if t.val.to_f - s.start_tm > s.time_out
        [s.time_out]
      end
    end

    timer_state <- (timer_state * alarm).lefts
  end
end
{'fraction_non_alphanumeric': 0.10360589131538853, 'fraction_numerical': 0.0030472320975114273, 'mean_word_length': 3.1561181434599157, 'pattern_counts': {'":': 0, '<': 17, '<?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': '2530088', 'n_tokens_mistral': 702, 'n_tokens_neox': 681, 'n_words': 220}