<commit_before>module LIFX
  class TagTable
    class Entry < Struct.new(:tag_id, :label, :site_id); end

    def initialize(entries: {})
      @entries = Hash.new { |h, k| h[k] = {} }
      entries.each do |k, v|
        @entries[k] = v
      end
    end

    def entries_with(tag_id: nil, site_id: nil, label: nil)
      @entries.values.map(&:values).flatten.select do |entry|
        ret = []
        ret << (entry.tag_id == tag_id) if tag_id
        ret << (entry.site_id == site_id) if site_id
        ret << (entry.label == label) if label
        ret.all?
      end
    end

    def entry_with(**args)
      entries_with(**args).first
    end

    def update_table(tag_id:, label:, site_id:)
      entry = @entries[site_id][tag_id] ||= Entry.new(tag_id, label, site_id)
      entry.label = label
    end

    def delete_entries_with(tag_id: nil, site_id: nil, label: nil)
      matching_entries = entries_with(tag_id: tag_id, site_id: site_id, label: label)
      matching_entries.each do |entry|
        @entries[entry.site_id].delete(entry.tag_id)
      end
    end

    def tags
      entries.map(&:label).uniq
    end

    def entries
      @entries.values.map(&:values.flatten)
    end
  end
end<commit_msg>Whoops<commit_after>module LIFX
  class TagTable
    class Entry < Struct.new(:tag_id, :label, :site_id); end

    def initialize(entries: {})
      @entries = Hash.new { |h, k| h[k] = {} }
      entries.each do |k, v|
        @entries[k] = v
      end
    end

    def entries_with(tag_id: nil, site_id: nil, label: nil)
      entries.select do |entry|
        ret = []
        ret << (entry.tag_id == tag_id) if tag_id
        ret << (entry.site_id == site_id) if site_id
        ret << (entry.label == label) if label
        ret.all?
      end
    end

    def entry_with(**args)
      entries_with(**args).first
    end

    def update_table(tag_id:, label:, site_id:)
      entry = @entries[site_id][tag_id] ||= Entry.new(tag_id, label, site_id)
      entry.label = label
    end

    def delete_entries_with(tag_id: nil, site_id: nil, label: nil)
      matching_entries = entries_with(tag_id: tag_id, site_id: site_id, label: label)
      matching_entries.each do |entry|
        @entries[entry.site_id].delete(entry.tag_id)
      end
    end

    def tags
      entries.map(&:label).uniq
    end

    def entries
      @entries.values.map(&:values).flatten
    end
  end
end
{'fraction_non_alphanumeric': 0.12578092461474386, 'fraction_numerical': 0.0, 'mean_word_length': 2.4710982658959537, 'pattern_counts': {'":': 0, '<': 17, '<?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': '880981', 'n_tokens_mistral': 854, 'n_tokens_neox': 835, 'n_words': 199}