<commit_before>module Baldr::Renderer
  class Json

  end
end<commit_msg>json renderer<commit_after>module Baldr::Renderer::Json

  extend self

  def draw(segment, params = {})
    draw_segment(segment).to_json
  end

  def draw_segment(segment)
    node = ActiveSupport::OrderedHash.new
    segment.elements.each.with_index { |e, i| node["#{segment.id}#{'%02d' % i}"] = e if e.present? }
    segment.children.each { |loop| node[loop.id] = loop.segments.map { |s| draw_segment(s) } }
    node
  end

end
{'fraction_non_alphanumeric': 0.14087301587301587, 'fraction_numerical': 0.003968253968253968, 'mean_word_length': 4.101010101010101, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5293965', 'n_tokens_mistral': 181, 'n_tokens_neox': 177, 'n_words': 36}