<commit_before>_ = lodash;

var NULL = 'NULL',
    escapeMetaCharacters = function (string) {
        return string.replace(/\$/g, '\\uff04').replace(/\./g, '\\uff0E');
    },
    unescapeMetaCharacters = function (string) {
        return string.replace(/\uff04/g, '$').replace(/\uff0E/g, '.');
    },
    Interactions = new Mongo.Collection('interactions', {
        transform: function (doc) {
            //workaround for dots in the keys (problem with mongo)
            doc.interaction = JSON.parse(unescapeMetaCharacters(JSON.stringify(doc.interaction)));
            return doc;
        }
    });

// This function is used to convert json paths that have dashes and cannot be used by jsonpath.query
// For example, it converts $.headers.content-type to $.headers["content-type"]
function escapeDashesInJsonPath(path) {
    var splitted = path.split(".");
    escapedPath = "";
    for (var i=0; i<splitted.length; i++) {
        var key = splitted[i];
        if (key.indexOf("-") === -1) {
            if (i > 0) {
                escapedPath += ".";
            }
            escapedPath += key;
        } else {
            escapedPath += '["' + key + '"]';
        }
    }<commit_msg>Unescaping float values in the mongo workaround<commit_after>_ = lodash;

var NULL = 'NULL',
    escapeMetaCharacters = function (string) {
        string = string.replace(/\$/g, '\\uff04').replace(/\./g, '\\uff0E');
        //NOTE: this method is a workaround for mongo not allowing certain characters in the keys
        //however, the method replaces all the characters in both keys and values. This causes the
        //issue that float values will be escaped, making the json string invalid and parse fails.
        //As a workaround for the workaround I unescape the float values in the string with a regex
        //I could not find an easy way to escape only the keys... :(
        return string.replace(/(":\d+)\\uff0E(\d+)/g, '$1.$2')
    },
    unescapeMetaCharacters = function (string) {
        return string.replace(/\uff04/g, '$').replace(/\uff0E/g, '.');
    },
    Interactions = new Mongo.Collection('interactions', {
        transform: function (doc) {
            //workaround for dots in the keys (problem with mongo)
            doc.interaction = JSON.parse(unescapeMetaCharacters(JSON.stringify(doc.interaction)));
            return doc;
        }
    });

// This function is used to convert json paths that have dashes and cannot be used by jsonpath.query
// For example, it converts $.headers.content-type to $.headers["content-type"]
function escapeDashesInJsonPath(path) {
    var splitted = path.split(".");
    escapedPath = "";
    for (var i=0; i<splitted.length; i++) {
        var key = splitted[i];
        if (key.indexOf("-") === -1) {
            if (i > 0) {
                escapedPath += ".";
            }
            escapedPath += key;
        } else {
            escapedPath += '["' + key + '"]';
        }
    }
{'fraction_non_alphanumeric': 0.14276048714479025, 'fraction_numerical': 0.007104194857916103, 'mean_word_length': 2.238773274917853, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, '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': '5497947', 'n_tokens_mistral': 862, 'n_tokens_neox': 850, 'n_words': 259}