<commit_before># encoding: utf-8

module RecastAI
  class Msg
    attr_reader :content, :type, :conversation_id

    def initialize(request)
      request = JSON.parse(request)
      request.each do |k, v|
        self.instance_variable_set("@#{k}", v)
        self.define_singleton_method(k.to_sym){ v }
      end

      @conversation_id = request['message']['conversation']
      @content = request['message']['attachment']['content']
      @type = request['message']['attachment']['type']
    end
  end
end<commit_msg>[FIX] snake_case the response keys<commit_after># encoding: utf-8

module RecastAI
  class Msg
    attr_reader :content, :type, :conversation_id

    def initialize(request)
      request = JSON.parse(request)
      request.each do |k, v|
        k = k.gsub(/(.)([A-Z])/,'\1_\2').downcase
        self.instance_variable_set("@#{k}", v)
        self.define_singleton_method(k.to_sym){ v }
      end

      @conversation_id = request['message']['conversation']
      @content = request['message']['attachment']['content']
      @type = request['message']['attachment']['type']
    end
  end
end
{'fraction_non_alphanumeric': 0.1545372866127583, 'fraction_numerical': 0.0035938903863432167, 'mean_word_length': 3.4206349206349205, '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': '966648', 'n_tokens_mistral': 350, 'n_tokens_neox': 346, 'n_words': 71}