<commit_before>
var
allFields = ["firstName","lastName","major","majorShort","email","phone","room","college","country","year","status","username"]; //all possible fields


//build some Regexes
var noQuoteQuery = new RegExp("("+allFields.join("|")+"):\\s?([^\\s\\\"\\']+)", "gi");
var singleQuoteQuery = new RegExp("("+allFields.join("|")+"):\\s?'([^']+)'", "gi");
var doubleQuoteQuery = new RegExp("("+allFields.join("|")+'):\\s?"([^"]+)"', "gi");

//some more Regexes
var yearRegEx = new RegExp("\\b(\\d{2})\\b", "gi");
var phoneRegEx = new RegExp("\\b(?:(?:00)?\\s?49\\s*)?(?:\\s*200)?\\s*(\\d{4})\\b", "gi");
var emailRegEx = new RegExp("\\b([\\w\\.]+)@((j(a(c(o(b(s(-(u(n(i(v(e(r(s(i(t(y(\\.(d(e)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?\\b|\\s|$)")

function escapeRegExp(str) {
    //escapes a string for a regexp.
    //from: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}

function escapeFullName(fullName){
    var names = fullName.replace("\\s+", " ").split(" ");
    names = names.map(function(e){
        return "(\\w+\\-)?"+e+"(\\-\\w+)?";
    });

    return names.join(" ([\\w]+ )*")
}

exports.parse = function (query) {
    var query = query || "";
    var result = null;
    var conditions = {};

    //find the full name query by just replaceing everything.
    var fullNameQuery = query
    .replace(noQuoteQuery, "")
    .replace(singleQuoteQuery, "")
    .replace(doubleQuoteQuery, "")
    .trim();

    //go over the phone
    result = phoneRegEx.exec(query);
    while (result != null) {
        conditions["phone"] = "^"+result[1]+"$";
        result = phoneRegEx.exec(query);
    }

    //replace the phone
    fullNameQuery = fullNameQuery.replace(phoneRegEx, "").trim();


    //go over the years
    result = yearRegEx.exec(query);
    while (result != null) {
        conditions["year"] = result[1]+"$";
        result = yearRegEx.exec(query);
    }

    //go over the emails
    result = emailRegEx.exec(query);
    while (result != null) {
        conditions["email"] = "^"+result[1]+"<EMAIL>$";
        result = emailRegEx.exec(query);
    }


    //replace the years
    fullNameQuery = fullNameQuery.replace(yearRegEx, "").trim();

    //iterate over the noQuote Results
    result = noQuoteQuery.exec(query);
    while (result != null) {
        conditions[result[1]] = escapeRegExp(result[2]).replace(", ", ",").split(",").join("|");
        result = noQuoteQuery.exec(query);
    }<commit_msg>Revert "Added email to autocomplete endpoint"<commit_after>
var
allFields = ["firstName","lastName","major","majorShort","email","phone","room","college","country","year","status","username"]; //all possible fields


//build some Regexes
var noQuoteQuery = new RegExp("("+allFields.join("|")+"):\\s?([^\\s\\\"\\']+)", "gi");
var singleQuoteQuery = new RegExp("("+allFields.join("|")+"):\\s?'([^']+)'", "gi");
var doubleQuoteQuery = new RegExp("("+allFields.join("|")+'):\\s?"([^"]+)"', "gi");

//some more Regexes
var yearRegEx = new RegExp("\\b(\\d{2})\\b", "gi");
var phoneRegEx = new RegExp("\\b(?:(?:00)?\\s?49\\s*)?(?:\\s*200)?\\s*(\\d{4})\\b", "gi");

function escapeRegExp(str) {
    //escapes a string for a regexp.
    //from: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}

function escapeFullName(fullName){
    var names = fullName.replace("\\s+", " ").split(" ");
    names = names.map(function(e){
        return "(\\w+\\-)?"+e+"(\\-\\w+)?";
    });

    return names.join(" ([\\w]+ )*")
}

exports.parse = function (query) {
    var query = query || "";
    var result = null;
    var conditions = {};

    //find the full name query by just replaceing everything.
    var fullNameQuery = query
    .replace(noQuoteQuery, "")
    .replace(singleQuoteQuery, "")
    .replace(doubleQuoteQuery, "")
    .trim();

    //go over the phone
    result = phoneRegEx.exec(query);
    while (result != null) {
        conditions["phone"] = "^"+result[1]+"$";
        result = phoneRegEx.exec(query);
    }

    //replace the phone
    fullNameQuery = fullNameQuery.replace(phoneRegEx, "").trim();


    //go over the years
    result = yearRegEx.exec(query);
    while (result != null) {
        conditions["year"] = result[1]+"$";
        result = yearRegEx.exec(query);
    }

    //replace the years
    fullNameQuery = fullNameQuery.replace(yearRegEx, "").trim();

    //iterate over the noQuote Results
    result = noQuoteQuery.exec(query);
    while (result != null) {
        conditions[result[1]] = escapeRegExp(result[2]).replace(", ", ",").split(",").join("|");
        result = noQuoteQuery.exec(query);
    }
{'fraction_non_alphanumeric': 0.2540914813260596, 'fraction_numerical': 0.0056651279899286614, 'mean_word_length': 3.244879786286732, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '4288930', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1627, 'n_words': 308}