<commit_before>var TrieNode = (function() {
  function TrieNode(character) {
    this.character = character || '';
    this.children = {};
    this.string = '';
  }

  TrieNode.prototype.add = function(string, index) {
    var currChar = string[index];

    if (currChar) {
      if (!this.children[currChar]) {
        this.children[currChar] = new TrieNode(currChar);
      }
      this.children[currChar].add(string, index + 1);
    } else {
      this.string = string;
    }
  };

  TrieNode.prototype.search = function(string, index) {
    var currChar = string[index];

    if (currChar) {
      if (!this.children[currChar]) {
        return false;
      } else {
        return this.children[currChar].search(string, index + 1);
      }
    } else {
      return collectStrings(this);
    }
  };

  var collectStrings = function(node) {
    var strings = [];

    if (node.string) {
      strings.push(node.string);
    }

    for (var child in node.children) {
      strings = strings.concat(collectStrings(node.children[child]));
    }

    return strings;
  };

  TrieNode.prototype.find = function(string, index) {
    var currChar = string[index];

    if (currChar) {
      if (!this.children[currChar]) {
        return false;
      } else {
        return this.children[currChar].find(string, index + 1);
      }
    } else {
      return this.string || false;
    }
  };

  return TrieNode;
})();

module.exports = TrieNode;
<commit_msg>Fix return value for empty search string<commit_after>var TrieNode = (function() {
  function TrieNode(character) {
    this.character = character || '';
    this.children = {};
    this.string = '';
  }

  TrieNode.prototype.add = function(string, index) {
    var currChar = string[index];

    if (currChar) {
      if (!this.children[currChar]) {
        this.children[currChar] = new TrieNode(currChar);
      }
      this.children[currChar].add(string, index + 1);
    } else {
      this.string = string;
    }
  };

  TrieNode.prototype.search = function(string, index) {
    var currChar = string[index];

    if (currChar) {
      if (!this.children[currChar]) {
        return false;
      } else {
        return this.children[currChar].search(string, index + 1);
      }
    } else if (index === 0) {
      return false;
    } else {
      return collectStrings(this);
    }
  };

  var collectStrings = function(node) {
    var strings = [];

    if (node.string) {
      strings.push(node.string);
    }

    for (var child in node.children) {
      strings = strings.concat(collectStrings(node.children[child]));
    }

    return strings;
  };

  TrieNode.prototype.find = function(string, index) {
    var currChar = string[index];

    if (currChar) {
      if (!this.children[currChar]) {
        return false;
      } else {
        return this.children[currChar].find(string, index + 1);
      }
    } else {
      return this.string || false;
    }
  };

  return TrieNode;
})();

module.exports = TrieNode;

{'fraction_non_alphanumeric': 0.14003350083752095, 'fraction_numerical': 0.0023450586264656616, 'mean_word_length': 2.4243119266055047, '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': '1018157', 'n_tokens_mistral': 956, 'n_tokens_neox': 932, 'n_words': 192}