<commit_before>{EventEmitter} = require 'events'

User = require './user'

class Brain extends EventEmitter
  # Represents somewhat persistent storage for the robot. Extend this.
  #
  # Returns a new Brain with no external storage.
  constructor: (@robot) ->
    @data =
      users:    { }
      talks:    { }
      domains:  { }
      _private: { }

    @autoSave = true

    robot.on "running", =>
      @resetSaveInterval 5

  # Public: Store key-value pair under the private namespace and extend
  # existing @data before emitting the 'loaded' event.
  #
  # Returns the instance for chaining.
  set: (key, value) ->
    if key is Object(key)
      pair = key
    else
      pair = {}
      pair[key] = value

    extend @data._private, pair
    @emit 'loaded', @data
    @

  # Public: Get value by key from the private namespace in @data
  # or return null if not found.
  #
  # Returns the value.
  get: (key) ->
    @data._private[key] ? null

  # Public: Remove value by key from the private namespace in @data<commit_msg>robot 変数の参照エラーがでていたので修正。<commit_after>{EventEmitter} = require 'events'

User = require './user'

class Brain extends EventEmitter
  # Represents somewhat persistent storage for the robot. Extend this.
  #
  # Returns a new Brain with no external storage.
  constructor: (@robot) ->
    @data =
      users:    { }
      talks:    { }
      domains:  { }
      _private: { }

    @autoSave = true

    @robot.on "running", =>
      @resetSaveInterval 5

  # Public: Store key-value pair under the private namespace and extend
  # existing @data before emitting the 'loaded' event.
  #
  # Returns the instance for chaining.
  set: (key, value) ->
    if key is Object(key)
      pair = key
    else
      pair = {}
      pair[key] = value

    extend @data._private, pair
    @emit 'loaded', @data
    @

  # Public: Get value by key from the private namespace in @data
  # or return null if not found.
  #
  # Returns the value.
  get: (key) ->
    @data._private[key] ? null

  # Public: Remove value by key from the private namespace in @data
{'fraction_non_alphanumeric': 0.10105871029836382, 'fraction_numerical': 0.0009624639076034649, 'mean_word_length': 2.523728813559322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4845806', 'n_tokens_mistral': 647, 'n_tokens_neox': 633, 'n_words': 232}