<commit_before>module TransformationHelper

  def transform(step_class, source, target, options = {})
    transformer = Metacrunch::Transformer.new
    transformer.register_helper(Metacrunch::UBPB::Transformations::MAB2SNR::Helpers::CommonHelper)

    transformer.source  = source
    transformer.target  = target
    transformer.options = options

    transformer.transform(step_class)

    transformer
  end

  def mab_builder(&block)
    Metacrunch::Mab2::Builder.build(&block)
  end

end<commit_msg>New helper for DRY testing.<commit_after>module TransformationHelper

  def transform(step_class, source, target, options = {})
    transformer = Metacrunch::Transformer.new
    transformer.register_helper(Metacrunch::UBPB::Transformations::MAB2SNR::Helpers::CommonHelper)

    transformer.source  = source
    transformer.target  = target
    transformer.options = options

    transformer.transform(step_class)

    transformer
  end

  def mab_builder(&block)
    Metacrunch::Mab2::Builder.build(&block)
  end

  def mab2snr(mab)
    transformer = transform(described_class, mab, Metacrunch::SNR.new)
    Mab2SnrResult.new(transformer)
  end

  class Mab2SnrResult
    attr_reader :transformer

    def initialize(transformer)
      @transformer = transformer
    end

    def values(path)
      @transformer.target.values(path)
    end

    def first_value(path)
      values(path).first
    end
  end

end
{'fraction_non_alphanumeric': 0.08987968860580325, 'fraction_numerical': 0.004953998584571833, 'mean_word_length': 4.160583941605839, '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': '1066300', 'n_tokens_mistral': 455, 'n_tokens_neox': 443, 'n_words': 77}