<commit_before>class PalletJack
  class KeyTransformer
    class Reader < KeyTransformer
      def concatenate(value,param)
        value.split(param) if value
      end
    end

    class Writer < KeyTransformer
      def concatenate(value,param)
        value.join(param) if value
      end

      def synthesize(value, param, result=String.new)
        return if value

        case param
        when String
          rex=/#\[([a-z0-9.-_]+)\]/i
          if md=rex.match(param) then
            result << md.pre_match
            return unless lookup = @pallet[md[1]]
            result << lookup.to_s
            synthesize(false, md.post_match, result)
          else
            result
          end
        else
          param.reduce(false) do |found_one, alternative|
            found_one || synthesize(false, alternative)
          end
        end
      end

      # Synthesize a pallet value from others, using regular
      # expressions to pull out parts of values.<commit_msg>Add rdoc comments for PalletJack::KeyTransformer::Writer.synthesize()<commit_after>class PalletJack
  class KeyTransformer
    class Reader < KeyTransformer
      def concatenate(value,param)
        value.split(param) if value
      end
    end

    class Writer < KeyTransformer
      def concatenate(value,param)
        value.join(param) if value
      end

      # Synthesize a pallet value by pasting others together.
      #
      # :call-seq:
      #   synthesize(nil, param)   -> string or nil
      #   synthesize(value, param) -> nil
      #
      # If +value+ is given, an earlier transform has already produced
      # a value for this key, so do nothing and return +nil+.
      #
      # Otherwise, use the parsed YAML structure in +param+ to build
      # and return a new value. If any failure occurs while building
      # the new value, return +nil+ to let another transform try.
      #
      # YAML structure:
      #
      #   synthesize:
      #     - "rule"
      #     - "rule"
      #     ...
      #
      # Rules are strings used to build the new value. The value of
      # another key is inserted by <tt>#[key]</tt>, and all other
      # characters are copied verbatim.
      #
      # Rules are evaluated in order, and the first one to
      # successfully produce a value without failing a key lookup is
      # used.
      #
      # Example:
      #
      #   - chassis.nic.name:
      #      synthesize:
      #        - "p#[chassis.nic.pcislot]p#[chassis.nic.port]"
      #        - "em#[chassis.nic.port]"

      def synthesize(value, param, result=String.new)
        return if value

        case param
        when String
          rex=/#\[([a-z0-9.-_]+)\]/i
          if md=rex.match(param) then
            result << md.pre_match
            return unless lookup = @pallet[md[1]]
            result << lookup.to_s
            synthesize(false, md.post_match, result)
          else
            result
          end
        else
          param.reduce(false) do |found_one, alternative|
            found_one || synthesize(false, alternative)
          end
        end
      end

      # Synthesize a pallet value from others, using regular
      # expressions to pull out parts of values.
{'fraction_non_alphanumeric': 0.08475628686743247, 'fraction_numerical': 0.0018627755355479665, 'mean_word_length': 1.782383419689119, 'pattern_counts': {'":': 0, '<': 17, '<?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': '4100825', 'n_tokens_mistral': 932, 'n_tokens_neox': 888, 'n_words': 284}