<commit_before>require 'pubcloud/spiral_iterator'

class Arranger

  def initialize(freq, text_size, max_font_em=4.5)
    @freq = freq
    @text_size = text_size
    @font_multiplier = max_font_em / Math.log10(freq.values.max)
  end

  # in ems
  def font_size(str)
    @font_multiplier * Math.log10(@freq[str])
  end

  def lay_it_out(g)
    raise unless g.is_a? LayoutGrid
    table = sort_freq
    table.each do |t|
      #TODO Only supports square layouts!
      SpiralIterator.new(g.width, {:row => g.width/2,:col => g.width/2}).each do |row, col |
        ret = g.add!(GridBlock.new(Token.new(t[0]), 1.0), row, col)
        puts "Attempting to put #{t.inspect} at #{row},#{col}... result: #{ret}"<commit_msg>Disabling a debug statement<commit_after>require 'pubcloud/spiral_iterator'

class Arranger

  def initialize(freq, text_size, max_font_em=4.5)
    @freq = freq
    @text_size = text_size
    @font_multiplier = max_font_em / Math.log10(freq.values.max)
  end

  # in ems
  def font_size(str)
    @font_multiplier * Math.log10(@freq[str])
  end

  def lay_it_out(g)
    raise unless g.is_a? LayoutGrid
    table = sort_freq
    table.each do |t|
      #TODO Only supports square layouts!
      SpiralIterator.new(g.width, {:row => g.width/2,:col => g.width/2}).each do |row, col |
        ret = g.add!(GridBlock.new(Token.new(t[0]), 1.0), row, col)
        #puts "Attempting to put #{t.inspect} at #{row},#{col}... result: #{ret}"
{'fraction_non_alphanumeric': 0.14483714483714483, 'fraction_numerical': 0.015246015246015246, 'mean_word_length': 3.2976190476190474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5797581', 'n_tokens_mistral': 557, 'n_tokens_neox': 549, 'n_words': 122}