<commit_before>function HelperMethods() {
  // Cache
  this._index = {};
}

// Define findIndex function to check if a term already exists
HelperMethods.prototype.findIndex = function(data, term) {
    return data.hasOwnProperty(term) ? data[term] : [];
};

// Define cleanUp function the replaces special characters in a string
HelperMethods.prototype.cleanUp = function(wordsToBeCleaned) {
    return wordsToBeCleaned.replace(/[^a-zA-Z\s]/g, '').toLowerCase();
};

// Define readFile function
HelperMethods.prototype.readFile = function(filePath) {
    var content = [];

    $.ajax({
        url: filePath,
        async: false,
        dataType: 'json',
        error: function(err) {
            console.log('Could not read JSON file');
        },
        success: function(data) {
            content = data;
        }
    });

    return content;
};

// Does the indexing of the word in the object
HelperMethods.prototype.doIndexing = function(bookIndex, booksData) {
    for (var word in booksData) {
        if (this._index[booksData[word]]) {
          if (!~this._index[booksData[word]].indexOf(bookIndex)){
            this._index[booksData[word]].push(bookIndex);
          }
        } else {
            this._index[booksData[word]] = [bookIndex];
        }
    }
};

HelperMethods.prototype.doSearch = function(index, terms) {
    var mapFn = function(term) {
        return helper.findIndex(index, term);
    };

    return terms.map(mapFn);
};

var helper = new HelperMethods();<commit_msg>Correct comments<commit_after>function HelperMethods() {
  // Cache
  this._index = {};
}

// Define findIndex function to check if a term already exists
HelperMethods.prototype.findIndex = function(data, term) {
    return data.hasOwnProperty(term) ? data[term] : [];
};

// Define cleanUp function that replaces special characters in a string
HelperMethods.prototype.cleanUp = function(wordsToBeCleaned) {
    return wordsToBeCleaned.replace(/[^a-zA-Z\s]/g, '').toLowerCase();
};

// Define readFile function that reads the JSON file
HelperMethods.prototype.readFile = function(filePath) {
    var content = [];

    $.ajax({
        url: filePath,
        async: false,
        dataType: 'json',
        error: function(err) {
            console.log('Could not read JSON file');
        },
        success: function(data) {
            content = data;
        }
    });

    return content;
};

// Does the indexing of the words in the object
HelperMethods.prototype.doIndexing = function(bookIndex, booksData) {
    for (var word in booksData) {
        if (this._index[booksData[word]]) {
          if (!~this._index[booksData[word]].indexOf(bookIndex)){
            this._index[booksData[word]].push(bookIndex);
          }
        } else {
            this._index[booksData[word]] = [bookIndex];
        }
    }
};

// Does the searching of the terms in the index
HelperMethods.prototype.doSearch = function(index, terms) {
    var mapFn = function(term) {
        return helper.findIndex(index, term);
    };

    return terms.map(mapFn);
};

var helper = new HelperMethods();
{'fraction_non_alphanumeric': 0.12871927554980594, 'fraction_numerical': 0.0, 'mean_word_length': 2.7765567765567765, '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': '5422258', 'n_tokens_mistral': 897, 'n_tokens_neox': 889, 'n_words': 218}