<commit_before>class Wc 
  attr_reader :filename, :occurrences, :words
  
  def initialize(filename, words)
    @filename = filename
    @occurrences = read
    @sorted = Array(occurrences).sort { |one, two| -(one[1] <=> two[1]) }
    @words = words
  end
  
  def to_text
    if @words == -1
      @sorted.each { |elem|
        puts "\"#{elem[0]}\" has #{elem[1]} occurrences"
      }
    else 
      @sorted[0..@words-1].each { |elem|
        puts "\"#{elem[0]}\" has #{elem[1]} occurrences"
      }
    end
  end
  
  def to_json
    if @words == -1
      return @sorted.to_json
    else
      return @sorted[0..@words-1].to_json
    end
  end
  
  def to_cloud
    if @words == -1
      cloud_items = @sorted
    else
      cloud_item = @sorted[0..@words-1]
    end
    ret = "<dl>"
    cloud_item.each { |elem|
      ret+="<dt>" + elem[0] +"</dt>"
    }
    ret += "</dl>"
    ret
  end
  
  private
  
  def read() 
    occurrences = Hash.new { |h, k| h[k] = 0 }
    File.open(@filename, "r") { |f|
          f.each_line { |line|
            words = line.split
            words.each { |w| occurrences[w] += 1 }
          }
        }
    occurrences
  end
  
  
  
end<commit_msg>to_cloud: now an ordinal number is placed as id field for dt elements. Useful if styling the cloud with a CSS<commit_after>class Wc 
  attr_reader :filename, :occurrences, :words
  
  def initialize(filename, words)
    @filename = filename
    @occurrences = read
    @sorted = Array(occurrences).sort { |one, two| -(one[1] <=> two[1]) }
    @words = words
  end
  
  def to_text
    if @words == -1
      @sorted.each { |elem|
        puts "\"#{elem[0]}\" has #{elem[1]} occurrences"
      }
    else 
      @sorted[0..@words-1].each { |elem|
        puts "\"#{elem[0]}\" has #{elem[1]} occurrences"
      }
    end
  end
  
  def to_json
    if @words == -1
      return @sorted.to_json
    else
      return @sorted[0..@words-1].to_json
    end
  end
  
  def to_cloud
    if @words == -1
      cloud_items = @sorted
    else
      cloud_item = @sorted[0..@words-1]
    end
    ret = "<dl>"
    i=1
    cloud_item.each { |elem|
      ret+="<dt id=\""+i.to_s+"\">" + elem[0] +"</dt>"
      i+=1
    }
    ret += "</dl>"
    ret
  end
  
  private
  
  def read() 
    occurrences = Hash.new { |h, k| h[k] = 0 }
    File.open(@filename, "r") { |f|
          f.each_line { |line|
            words = line.split
            words.each { |w| occurrences[w] += 1 }
          }
        }
    occurrences
  end
  
  
  
end
{'fraction_non_alphanumeric': 0.15768463073852296, 'fraction_numerical': 0.015169660678642715, 'mean_word_length': 1.834841628959276, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '587261', 'n_tokens_mistral': 975, 'n_tokens_neox': 934, 'n_words': 224}