<commit_before>'use strict'
var hash = require('../../util/hash')
/**
 * @property uid
 * injectable for generation of uids -- handy if you want weakmap-like behaviour
 * @memberOf Base#
 * @param {object} val
*/
exports.define = {
  uid: {
    get () {
      if (!this.hasOwnProperty('_uid')) {
        let parent = this
        let str = ''
        while (parent && parent.key) {
          str += parent.key
          parent = parent._parent
        }
        this._uid = '~' + str // hash // will create collisions -- so thats not so good -- make entry points on val?
      }
      return this._uid
    }
  },
  getHashedPath (cache) {
    if (this._context) {
      if (!cache) {
        cache = this.contextMap()
      }
      if (cache.val) {
        return cache.val
      }
      let parent = this
      let str = ''
      while (parent && parent.key) {
        str += parent.key
        let lparent = parent
        let cntx = parent._context
        let level = parent._contextLevel
        parent = parent.parent
        if (lparent._context !== cntx) {
          lparent._context = cntx || null
          lparent._contextLevel = level || null
        }
      }
      cache.val = '~' + str
      return cache.val
    } else {
      return this.uid
    }
  }
}<commit_msg>hashed path uids<commit_after>'use strict'
var hash = require('../../util/hash')
/**
 * @property uid
 * injectable for generation of uids -- handy if you want weakmap-like behaviour
 * @memberOf Base#
 * @param {object} val
*/
exports.define = {
  uid: {
    get () {
      if (!this.hasOwnProperty('_uid')) {
        let parent = this
        let str = ''
        while (parent && parent.key) {
          str += parent.key
          parent = parent._parent
        }
        this._uid = hash(str) // hash // will create collisions -- so thats not so good -- make entry points on val?
      }
      return this._uid
    }
  },
  getHashedPath (cache) {
    if (this._context) {
      if (!cache) {
        cache = this.contextMap()
      }
      if (cache.val) {
        return cache.val
      }
      let parent = this
      let str = ''
      while (parent && parent.key) {
        str += parent.key
        let lparent = parent
        let cntx = parent._context
        let level = parent._contextLevel
        parent = parent.parent
        if (lparent._context !== cntx) {
          lparent._context = cntx || null
          lparent._contextLevel = level || null
        }
      }
      cache.val = hash(str)
      return cache.val
    } else {
      return this.uid
    }
  }
}
{'fraction_non_alphanumeric': 0.12310089598753408, 'fraction_numerical': 0.0, 'mean_word_length': 1.672216441207076, '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': '2840659', 'n_tokens_mistral': 753, 'n_tokens_neox': 757, 'n_words': 216}