<commit_before>var inflect = require('i')()
  , fs = require('fs')
  , path = require('path')
  , mkdirp = require('mkdirp')
  , NeDB = require('nedb')
  , RSVP = require('rsvp')
  , _ = require('lodash')
  , location = path.normalize(__dirname);

var adapter = {};

adapter._init = function(options) {
  // Store options
  this._options = options;
};

adapter.schema = function(name, schema, options) {
  _.each(schema, function(val, key) {
    var obj = {}
      , isArray = _.isArray(val)
      , value = isArray ? val[0] : val
      , isObject = _.isPlainObject(value)
      , ref = isObject ? value.ref : value
      , inverse = isObject ? value.inverse : undefined;

    // Convert string to association object
    if(typeof ref === 'string') {
      obj.ref = ref;
      obj.inverse = inverse;
      schema[key] = isArray ? [obj] : obj;
    }

    // Wrap native type in object
    if(typeof value === 'function') {
      schema[key] = isArray ? [{type: schema[key]}] : {type: schema[key]};
    }

  });
  this._schemas[name] = schema;
  return schema;
};

adapter.model = function(name, schema) {
  if(schema) {
    var dbPath = location + '/../../data/' + this._options.db
      , filePath = dbPath + '/' + inflect.pluralize(name)
      , options = {
      filename: filePath,
      autoload: true
    };
    options = _.extend(options, options.flags);

    if(!options.inMemoryOnly) {
      mkdirp.sync(dbPath);
      fs.exists(filePath, function(exists) {
        if(!exists) {
            fs.writeFileSync(filePath, '');
        }
      });
    }

    // Actually set up a database
    var db = new NeDB(options);

    // Store the model name in a private key
    db._name = name;

    this._models[name] = db;
    return db;
  } else {
    return this._models[name];
  }
};

adapter.create = function(model, id, resource) {
  var _this = this;

  if(!resource) {
    resource = id;
  } else {<commit_msg>fix typo<commit_after>var inflect = require('i')()
  , fs = require('fs')
  , path = require('path')
  , mkdirp = require('mkdirp')
  , NeDB = require('nedb')
  , RSVP = require('rsvp')
  , _ = require('lodash')
  , location = path.normalize(__dirname);

var adapter = {};

adapter._init = function(options) {
  // Store options
  this._options = options;
};

adapter.schema = function(name, schema, options) {
  _.each(schema, function(val, key) {
    var obj = {}
      , isArray = _.isArray(val)
      , value = isArray ? val[0] : val
      , isObject = _.isPlainObject(value)
      , ref = isObject ? value.ref : value
      , inverse = isObject ? value.inverse : undefined;

    // Convert string to association object
    if(typeof ref === 'string') {
      obj.ref = ref;
      obj.inverse = inverse;
      schema[key] = isArray ? [obj] : obj;
    }

    // Wrap native type in object
    if(typeof value === 'function') {
      schema[key] = isArray ? [{type: schema[key]}] : {type: schema[key]};
    }

  });
  this._schemas[name] = schema;
  return schema;
};

adapter.model = function(name, schema) {
  if(schema) {
    var dbPath = location + '/../../data/' + this._options.db
      , filePath = dbPath + '/' + inflect.pluralize(name)
      , options = {
      filename: filePath,
      autoload: true
    };
    options = _.extend(options, this._options.flags);

    if(!options.inMemoryOnly) {
      mkdirp.sync(dbPath);
      fs.exists(filePath, function(exists) {
        if(!exists) {
            fs.writeFileSync(filePath, '');
        }
      });
    }

    // Actually set up a database
    var db = new NeDB(options);

    // Store the model name in a private key
    db._name = name;

    this._models[name] = db;
    return db;
  } else {
    return this._models[name];
  }
};

adapter.create = function(model, id, resource) {
  var _this = this;

  if(!resource) {
    resource = id;
  } else {
{'fraction_non_alphanumeric': 0.15671447196870925, 'fraction_numerical': 0.0005215123859191656, 'mean_word_length': 2.496809480401094, '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': '6470521', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1250, 'n_words': 293}