<commit_before>(function (global, smx, Sizzle) {


/**
 * SMX Document Class
 * @memberof smx
 */
class Document {
  
  /**
   * @param {XMLDocument}
   */
  constructor(xmlDocument) {
    
    //requires DOCUMENT_NODE
    if(xmlDocument.nodeType!==9)
      throw(new Error('Document constructor requires DOCUMENT_NODE'));
    
    /**
     * Original XMLDocument for reference
     * @type {XMLDocument}
     * @readonly
     */
    this[0] = xmlDocument;
    
    /**
     * Contains an id &rarr; key map of all processed nodes for easy acccess.
     * @type {Object}
     * @private
     */
    this._cache = {};
    
  }

  /**
   * Gets Uniform Resource Locator
   * Concatenation of path values from parent nodes up to document root
   * @type {String}
   * @readonly
   */
  get path() {
    var path = this[0].URL.split('/');
    path.pop(); return path.join('/');
  }

  /**
   * Gets the source file url for this document.
   * @type {String}
   * @readonly
   */
  get src() {
    return this[0].URL;
  }

  /**
   * Gets the root node.
   * @type {SMXNode}
   * @readonly
   */
  get root() {
    return this.wrap(this[0].lastChild);
  }

  /**
   * Gets the node with the given identifier.
   * @memberof smx.fn.TreeNode
   * @alias gid
   * @return {SMXNode}
   */
  getNodeById(id){
      
    //cached id?
    if(this._cache[id]) return this._cache[id];
    
    //search in document
    var xmlNode = this[0].getElementById(id);
    
    //not found
    return this.wrap(xmlNode);

  }

  gid(id){ return this.getNodeById(id) }
  
  /**
   * Finds all nodes matching the given selector.
   * @param {String} selector - search selector
   * @param {SMXNode=} context - node context to find inside
   * @return {Array.<SMXNode>}
   */
  find(selector, ctxNode) {
    
    if (!selector) return [];
    var nodes = Sizzle(selector,(ctxNode||this)[0]);
    return this.wrap(nodes);
    
  }
  
  /**
   * Wraps an existing node or nodes in smx paradigm.
   * @param {XMLNode|XMLNode[]}
   * @return {SMXNode|SMXNode[]}
   */
  wrap(s){
    
    if(!s) return;
    
    var _this = this;
    var _wrapNode = function (xmlNode) {
      <commit_msg>remove `gid` alias for `getNodeById` from SMXDocument<commit_after>(function (global, smx, Sizzle) {


/**
 * SMX Document Class
 * @memberof smx
 */
class Document {
  
  /**
   * @param {XMLDocument}
   */
  constructor(xmlDocument) {
    
    //requires DOCUMENT_NODE
    if(xmlDocument.nodeType!==9)
      throw(new Error('Document constructor requires DOCUMENT_NODE'));
    
    /**
     * Original XMLDocument for reference
     * @type {XMLDocument}
     * @protected
     */
    this[0] = xmlDocument;
    
    /**
     * Contains an id &rarr; key map of all processed nodes for easy acccess.
     * @type {Object}
     * @private
     */
    this._cache = {};
    
  }

  /**
   * Gets Uniform Resource Locator
   * Concatenation of path values from parent nodes up to document root
   * @type {String}
   * @readonly
   */
  get path() {
    var path = this[0].URL.split('/');
    path.pop(); return path.join('/');
  }

  /**
   * Gets the source file url for this document.
   * @type {String}
   * @readonly
   */
  get src() {
    return this[0].URL;
  }

  /**
   * Gets the root node.
   * @type {SMXNode}
   * @readonly
   */
  get root() {
    return this.wrap(this[0].lastChild);
  }

  /**
   * Gets the node with the given identifier.
   * @param {String} id
   * @return {SMXNode}
   */
  getNodeById(id){
      
    //cached id?
    if(this._cache[id]) return this._cache[id];
    
    //search in document
    var xmlNode = this[0].getElementById(id);
    
    //not found
    return this.wrap(xmlNode);

  }

  //gid(id){ return this.getNodeById(id) }
  
  /**
   * Finds all nodes matching the given selector.
   * @param {String} selector - search selector
   * @param {SMXNode=} context - node context to find inside
   * @return {Array.<SMXNode>}
   */
  find(selector, ctxNode) {
    
    if (!selector) return [];
    var nodes = Sizzle(selector,(ctxNode||this)[0]);
    return this.wrap(nodes);
    
  }
  
  /**
   * Wraps an existing node or nodes in smx paradigm.
   * @param {XMLNode|XMLNode[]}
   * @return {SMXNode|SMXNode[]}
   */
  wrap(s){
    
    if(!s) return;
    
    var _this = this;
    var _wrapNode = function (xmlNode) {
      
{'fraction_non_alphanumeric': 0.14200092208390963, 'fraction_numerical': 0.003227293683725219, 'mean_word_length': 2.2575075075075075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '6056432', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1456, 'n_words': 379}