<commit_before>###
  backbone-orm.js 0.0.1
  Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-orm
  License: MIT (http://www.opensource.org/licenses/mit-license.php)
  Dependencies: Backbone.js and Underscore.js.
###
_ = require 'underscore'
crypto = require('crypto');

module.exports = class ModelTypeID

  constructor: ->
    @ids = {}

  reset: =>
    @ids = {}

  modelID: (model_type) =>
    name_url = "#{_.result(model_type.prototype, 'url')}_#{model_type.model_name}"
    return crypto.createHash('md5').update(name_url).digest('hex')

  generate: (model_type) =>
    id = @modelID(model_type)
    if @ids[id] and @ids[id] isnt model_type
      throw new Error("Duplicate model name / url combination: #{model_type.model_name}, #{_.result(model_type.prototype, 'url')}. Set a unique model_name property on one of the conflicting models.")
    @ids[id] = model_type
    return id
<commit_msg>Bug fix for url<commit_after>###
  backbone-orm.js 0.0.1
  Copyright (c) 2013 Vidigami - https://github.com/vidigami/backbone-orm
  License: MIT (http://www.opensource.org/licenses/mit-license.php)
  Dependencies: Backbone.js and Underscore.js.
###
_ = require 'underscore'
crypto = require 'crypto'

module.exports = class ModelTypeID

  constructor: ->
    @ids = {}

  reset: =>
    @ids = {}

  modelID: (model_type) =>
    try url = _.result(model_type.prototype, 'url') catch err then {}
    name_url = "#{url or ''}_#{model_type.model_name}"
    return crypto.createHash('md5').update(name_url).digest('hex')

  generate: (model_type) =>
    id = @modelID(model_type)
    if @ids[id] and @ids[id] isnt model_type
      throw new Error("Duplicate model name / url combination: #{model_type.model_name}, #{_.result(model_type.prototype, 'url')}. Set a unique model_name property on one of the conflicting models.")
    @ids[id] = model_type
    return id

{'fraction_non_alphanumeric': 0.15122470713525027, 'fraction_numerical': 0.008519701810436636, 'mean_word_length': 3.931758530183727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4203618', 'n_tokens_mistral': 655, 'n_tokens_neox': 629, 'n_words': 148}