<commit_before>require "set"

# based on RestricedSet from Ruby's stdlib, cf
# http://github.com/ruby/ruby/blob/72ef219804e5524848170a197887a95718334e2a/lib/set.rb#L627-717
# not sure why it's been commented out
# I should follow these things

class TypedSet < Set
  attr_reader :klass
  alias set_class klass

  def initialize (klass, *args)
    raise ArgumentError, "require a Class object" unless klass.class == Class
    @klass = klass
    super args
  end

  def add o
    raise ArgumentError, "members must be of class #{@klass}" unless o.class == @klass
    super o
  end
  alias << add
end<commit_msg>clean up TypedSet class<commit_after>require "set"

class TypedSet < Set
  attr_reader :set_class

  def initialize (klass, *args)
    raise ArgumentError, "require a class object" unless klass.class == Class
    @set_class = klass
    super args
  end

  def add o
    unless o.class == @set_class
      raise ArgumentError, "members must be of class #{ @set_class }"
    end

    super o
  end
  alias << add
end
{'fraction_non_alphanumeric': 0.08211143695014662, 'fraction_numerical': 0.03812316715542522, 'mean_word_length': 3.432900432900433, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7412281', 'n_tokens_mistral': 357, 'n_tokens_neox': 335, 'n_words': 116}