<commit_before>require 'ostruct'

class Mws::Serializer

  def initialize(exceptions={})
    @exceptions = exceptions
  end

  def xml_for(data, builder, context=nil)
    data.each do | key, value |
      element = Mws::Utils.camelize(key)
      path = [ context, key ].compact.join '.'
      if @exceptions.include? path
        @exceptions[path].first.call(key, value, builder, path)
      elsif value.respond_to? :keys
        builder.send(element) { |b| xml_for(value, b, path) }
      elsif value.respond_to? :each
        value.each do | val |
          builder.send(element) { |b| xml_for(val, b, path)}
        end
      else
        builder.send element, value
      end
    end
  end

  def struct_for(doc)

  end

end
<commit_msg>Add support for arrays of scalar values<commit_after>require 'ostruct'

class Mws::Serializer

  def initialize(exceptions={})
    @exceptions = exceptions
  end

  def xml_for(data, builder, context=nil)
    data.each do | key, value |
      element = Mws::Utils.camelize(key)
      path = [ context, key ].compact.join '.'
      if @exceptions.include? path
        @exceptions[path].first.call(key, value, builder, path)
      elsif value.respond_to? :keys
        builder.send(element) { |b| xml_for(value, b, path) }
      elsif value.respond_to? :each
        value.each do | val |
          if val.respond_to? :keys
            builder.send(element) { |b| xml_for(val, b, path)}
          else
            builder.send element, val      
          end
        end
      else
        builder.send element, value
      end
    end
  end

  def struct_for(doc)

  end

end

{'fraction_non_alphanumeric': 0.10939431396786156, 'fraction_numerical': 0.0, 'mean_word_length': 2.3381443298969073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '4514599', 'n_tokens_mistral': 527, 'n_tokens_neox': 516, 'n_words': 136}