<commit_before>require 'json'

module Aws
  # @api private
  module Json

    autoload :Builder, 'aws-sdk-core/json/builder'
    autoload :ErrorHandler, 'aws-sdk-core/json/error_handler'
    autoload :Handler, 'aws-sdk-core/json/handler'
    autoload :Parser, 'aws-sdk-core/json/parser'

    class ParseError < StandardError

      def initialize(error)
        @error = error
        super(error.message)
      end

      attr_reader :error

    end

    class << self

      def load(json)
        ENGINE.load(json)
      rescue ENGINE_ERROR => e
        raise ParseError.new(e)
      end

      def load_file(path)
        self.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
      end

      def dump(value)
        ENGINE.dump(value, ENGINE_DUMP_OPTIONS)
      end

      private

      def oj_engine
        require 'oj'
        [Oj, { mode: :compat }, Oj::ParseError]
      rescue LoadError
        false
      end

      def json_engine
        [JSON, {}, JSON::ParserError]
      end

    end

    # @api private
    ENGINE, ENGINE_DUMP_OPTIONS, ENGINE_ERROR = oj_engine || json_engine

  end
end
<commit_msg>Fix for broken JSON.dump call.<commit_after>require 'json'

module Aws
  # @api private
  module Json

    autoload :Builder, 'aws-sdk-core/json/builder'
    autoload :ErrorHandler, 'aws-sdk-core/json/error_handler'
    autoload :Handler, 'aws-sdk-core/json/handler'
    autoload :Parser, 'aws-sdk-core/json/parser'

    class ParseError < StandardError

      def initialize(error)
        @error = error
        super(error.message)
      end

      attr_reader :error

    end

    class << self

      def load(json)
        ENGINE.load(json)
      rescue ENGINE_ERROR => e
        raise ParseError.new(e)
      end

      def load_file(path)
        self.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
      end

      def dump(value)
        ENGINE.dump(value, *ENGINE_DUMP_OPTIONS)
      end

      private

      def oj_engine
        require 'oj'
        [Oj, [{ mode: :compat }], Oj::ParseError]
      rescue LoadError
        false
      end

      def json_engine
        [JSON, [], JSON::ParserError]
      end

    end

    # @api private
    ENGINE, ENGINE_DUMP_OPTIONS, ENGINE_ERROR = oj_engine || json_engine

  end
end

{'fraction_non_alphanumeric': 0.1021034180543383, 'fraction_numerical': 0.0008764241893076249, 'mean_word_length': 2.140302613480055, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '2540321', 'n_tokens_mistral': 789, 'n_tokens_neox': 748, 'n_words': 174}