<commit_before>require 'oj'

module Cellect
  class GroupedProject < Project
    attr_accessor :groups
    
    def initialize(name)
      super
      self.groups = { }
    end
    
    def load_data(data)
      transition :initializing
      self.subjects = set_klass.new
      klass = set_klass
      
      data.each do |hash|
        group ||= klass.new
        group(hash['group_id']).add hash['id'], hash['priority']
      end
      
      transition :ready
    end
    
    def load_data_from(path)
      load_json(path) do |json|
        json['entries'].each do |entry|
          self.groups[entry['group_id']] ||= DiffSet::RandomSet.new
          groups[entry['group_id']].add entry['id']
        end
      end
    end
    
    def group(group_id = nil)
      groups[group_id] || groups.values.sample
    end
    
    def unseen_for(user_name, group_id: nil, limit: 5)
      group(group_id).subtract user(user_name).seen, limit
    end
  end
end
<commit_msg>Cleaning up<commit_after>require 'oj'

module Cellect
  class GroupedProject < Project
    attr_accessor :groups
    
    def initialize(name)
      super
      self.groups = { }
    end
    
    def load_data(data)
      transition :initializing
      self.subjects = set_klass.new
      klass = set_klass
      
      data.each do |hash|
        group ||= klass.new
        group(hash['group_id']).add hash['id'], hash['priority']
      end
      
      transition :ready
    end
    
    def group(group_id = nil)
      groups[group_id] || groups.values.sample
    end
    
    def unseen_for(user_name, group_id: nil, limit: 5)
      group(group_id).subtract user(user_name).seen, limit
    end
  end
end

{'fraction_non_alphanumeric': 0.10083532219570406, 'fraction_numerical': 0.0011933174224343676, 'mean_word_length': 2.1821631878557874, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3492530', 'n_tokens_mistral': 540, 'n_tokens_neox': 543, 'n_words': 120}