<commit_before>class TreeMapNode < Node
  attr_accessor :state
  
  GRADIENT = ["#002F2F", "#003638", "#013d40", "#01444a", "#014a52", "#02505c", "#025563", "#025a6e", "#045f75", "#046380"]
  
  def initialize(id, name)
    super(id, name)
    
    #area
    @data[:$area] = 0
    @data[:count] = 0
    
    #color
    @data[:level] = 0
    @data[:$color] = GRADIENT[@data[:level]]
    
    fix_title_and_state
  end
  
  # adds a child to this node and updates the color of the child
  # returns the added child
  def add_child(child, root)
    child.data[:level] = @data[:level]+1 if @data[:level] < 9
    child.data[:$color] = GRADIENT[child.data[:level]]
    super(child, root)
  end
  
  # adds a number to the count variable and recalculates the area
  def add_count(count)
    @data[:count] += count
    @data[:$area] = Math.log10(@data[:count]+1)/Math.log10(2)
    
    fix_title_and_state
  end
  
  def fix_title_and_state
    @data[:title] = @name
    @data[:title] += " (" + (@data[:self_count].nil? ? "0" : @data[:self_count].to_s) + "/" + @data[:count].to_s + ")" unless @name == "root"
    
    @state = @data[:level] <= 3 ? "open" : "closed"
  end
end<commit_msg>fix numbers in leafs of jstree<commit_after>class TreeMapNode < Node
  attr_accessor :state
  
  GRADIENT = ["#002F2F", "#003638", "#013d40", "#01444a", "#014a52", "#02505c", "#025563", "#025a6e", "#045f75", "#046380"]
  
  def initialize(id, name)
    super(id, name)
    
    #area
    @data[:$area] = 0
    @data[:count] = 0
    
    #color
    @data[:level] = 0
    @data[:$color] = GRADIENT[@data[:level]]
    
    fix_title_and_state
  end
  
  # adds a child to this node and updates the color of the child
  # returns the added child
  def add_child(child, root)
    child.data[:level] = @data[:level]+1 if @data[:level] < 9
    child.data[:$color] = GRADIENT[child.data[:level]]
    super(child, root)
  end
  
  # adds a number to the count variable and recalculates the area
  def add_count(count)
    @data[:count] += count
    @data[:$area] = Math.log10(@data[:count]+1)/Math.log10(2)
    
    fix_title_and_state
  end
  
  def fix_title_and_state
    @data[:title] = @name
    if @children.length != 0
      @data[:title] += " (" + (@data[:self_count].nil? ? "0" : @data[:self_count].to_s) + "/" + @data[:count].to_s + ")" unless @name == "root"
    else
      @data[:title] += " (" + @data[:count].to_s + ")" unless @name == "root"
    end
      
    @state = @data[:level] <= 3 ? "open" : "closed"
  end
end
{'fraction_non_alphanumeric': 0.1797842588893328, 'fraction_numerical': 0.05153815421494207, 'mean_word_length': 3.1872909698996654, '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': '2458854', 'n_tokens_mistral': 1020, 'n_tokens_neox': 942, 'n_words': 216}