<commit_before>require 'json'
require 'waveapi/context'

module Waveapi
  class MessageBundle
    attr_reader :raw_data, :events, :wavelet, :blips, :robot_address

    def initialize(json_str, context)
      @context = context
      @context.message_bundle = self
      @raw_data = json_str
      @raw_json = JSON.parse(json_str).dup
      @robot_address = @raw_json['robotAddress']
      @wavelet = Wavelet.new(@raw_json['wavelet'], @context)
    end

    def blips
      unless @blips
        @blips = {}
        @raw_json['blips'].each{|bid, json| @blips[bid] = Blip.new(json, @context)}
      end
      @blips
    end

    def events
      @events ||= (@raw_json['events'] || []).map{|json| Blip.new(json, @context)}
    end
  end
end<commit_msg>fix a bug<commit_after>require 'json'
require 'waveapi/event'
require 'waveapi/context'

module Waveapi
  class MessageBundle
    attr_reader :raw_data, :events, :wavelet, :blips, :robot_address

    def initialize(json_str, context)
      @context = context
      @context.message_bundle = self
      @raw_data = json_str
      @raw_json = JSON.parse(json_str).dup
      @robot_address = @raw_json['robotAddress']
      @wavelet = Wavelet.new(@raw_json['wavelet'], @context)
    end

    def blips
      unless @blips
        @blips = {}
        @raw_json['blips'].each{|bid, json| @blips[bid] = Blip.new(json, @context)}
      end
      @blips
    end

    def events
      @events ||= (@raw_json['events'] || []).map{|json| Event.build(json, @context)}
    end
  end
end
{'fraction_non_alphanumeric': 0.1372291529875246, 'fraction_numerical': 0.0, 'mean_word_length': 3.0531914893617023, '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': '1182933', 'n_tokens_mistral': 532, 'n_tokens_neox': 517, 'n_words': 111}