<commit_before>(function(root) { "use_strict";

var _,
    util,
    errors,
    Store,
    Data;

if (typeof exports !== 'undefined') {
  _ = require('underscore');
  util = require('../lib/util/util');
  errors = require('../lib/util/errors');
  Store = require('./store').Store;
  Data = require('../lib/data/data');
} else {
  _ = root._;
  util = root.Substance.util;
  errors = root.Substance.errors;
  Store = root.Substance.Store;
  Data = root.Substance.Data;
}

var PersistentGraph = function(store, graph) {
  Data.Graph.call(this);
  this.__nodes__ = store.hash("nodes");
  if(graph) this.merge(graph);
};

PersistentGraph.__prototype__ = function() {
  var __super__ = util.prototype(this);

  // delegate all methods to graph
  _.each(Data.Graph.prototype, function(f, name) {
    if (_.isFunction(f)) {
      this[name] = function() {
        return this.graph[name].apply(this.graph, arguments);
      };
    }
  }, this);

  // Overrides
  // --------

  this.get = function(path) {
    if (_.isString(path)) return this.__nodes__.get(path);
    else return __super__.get.call(this, path);
  };

  this.delete = function(id) {
    this.removeFromIndex(this.get(id));
    this.store.delete(id);
  };

  this.reset = function() {
    __super__.reset.call(this);
    if (this.store) this.store.clear();
  };

};
PersistentGraph.__prototype__.prototype = Data.Graph.prototype;
PersistentGraph.prototype = new PersistentGraph.__prototype__();

if (typeof exports !== 'undefined') {
  module.exports = PersistentGraph;
} else {
  root.Substance.Data.PersistentGraph = PersistentGraph;
}

})(this);<commit_msg>Cleanup.<commit_after>(function(root) { "use_strict";

var _,
    util,
    errors,
    Store,
    Data;

if (typeof exports !== 'undefined') {
  _ = require('underscore');
  util = require('../lib/util/util');
  errors = require('../lib/util/errors');
  Store = require('./store').Store;
  Data = require('../lib/data/data');
} else {
  _ = root._;
  util = root.Substance.util;
  errors = root.Substance.errors;
  Store = root.Substance.Store;
  Data = root.Substance.Data;
}

var PersistentGraph = function(store, graph) {
  this.graph = graph;
  this.__nodes__ = store.hash("nodes");
};

PersistentGraph.__prototype__ = function() {

  var __super__ = util.prototype(this);

  // delegate all methods to graph
  _.each(Data.Graph.prototype, function(f, name) {
    if (_.isFunction(f)) {
      this[name] = function() {
        return this.graph[name].apply(this.graph, arguments);
      };
    }
  }, this);

  // Overrides
  // --------

  this.get = function(path) {
    if (_.isString(path)) return this.__nodes__.get(path);
    else return __super__.get.call(this, path);
  };

  this.delete = function(id) {
    this.graph.delete(id);
    this.store.delete(id);
  };

  this.reset = function() {
    this.graph.reset();
    if (this.store) this.store.clear();
  };

};
PersistentGraph.__prototype__.prototype = Data.Graph.prototype;
PersistentGraph.prototype = new PersistentGraph.__prototype__();

if (typeof exports !== 'undefined') {
  module.exports = PersistentGraph;
} else {
  root.Substance.Data.PersistentGraph = PersistentGraph;
}

})(this);
{'fraction_non_alphanumeric': 0.17321596982081106, 'fraction_numerical': 0.0, 'mean_word_length': 3.34106412005457, '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': '83022', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1040, 'n_words': 190}