<commit_before>module Bureaucrat
  module Utils
    extend self

    module SafeData
    end

    class SafeString < String
      include SafeData

      def +(rhs)
        rhs.is_a?(SafeString) ? SafeString.new(super(rhs)) : super(rhs)
      end
    end

    class StringAccessHash < Hash
      def initialize(other = {})
        super()
        update(other)
      end

      def []=(key, value)
        if value.respond_to? :gsub
          value = Utils.escape(value)
        end
        super(key.to_s, value)
      end

      def [](key)<commit_msg>SIT-243: SafeString.to_s is still safe<commit_after>module Bureaucrat
  module Utils
    extend self

    module SafeData
    end

    class SafeString < String
      include SafeData

      def to_s
        SafeString.new(self)
      end

      def +(rhs)
        rhs.is_a?(SafeString) ? SafeString.new(super(rhs)) : super(rhs)
      end
    end

    class StringAccessHash < Hash
      def initialize(other = {})
        super()
        update(other)
      end

      def []=(key, value)
        if value.respond_to? :gsub
          value = Utils.escape(value)
        end
        super(key.to_s, value)
      end

      def [](key)
{'fraction_non_alphanumeric': 0.09090909090909091, 'fraction_numerical': 0.0025252525252525255, 'mean_word_length': 1.8513189448441247, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2607481', 'n_tokens_mistral': 379, 'n_tokens_neox': 376, 'n_words': 93}