<commit_before>var tfidf = require('../tfidf');
var redis = require('redis').createClient();

function runTest() {
    var totalTermCount = 0;
    for (var prop in documents[documents.length - 1]) {
        if (documents[documents.length - 1].hasOwnProperty(prop)) {
            totalTermCount+=documents[documents.length-1][prop];
        }
    }
    tfidf.getScores(documents[documents.length-2], totalTermCount, function(scores) {

        tfidf.getScores(documents[documents.length-1], totalTermCount, function(scores) {
            var fail = false;
            console.log('score' + JSON.stringify(scores));
            for (var param in scores) {
                if (scores.hasOwnProperty(param)) {
                    if (param !== 'five' && 
                        scores[param] >= scores.five) {
                            fail = true;
                        }
                }
            }
            console.log('Test has pased: ' + (fail === false));
        });
    });
}

var documents = [];
documents.push({
    'one': 1,
    'two': 1,
    'three': 1,
    'four': 1
});

documents.push({
    'one': 1,
    'two': 1,
    'three': 1,
    'four': 1,
    'five': 1
});

var keysServiced = 0;
for (var key in documents[documents.length - 1]) {
    if (documents[documents.length - 1].hasOwnProperty(key)) {
        (function(key) {
            redis.set(key, 0, function(err, res) {
                keysServiced++;
                if (keysServiced === Object.keys(documents[documents.length - 1]).length) {
                    return runTest();
                }<commit_msg>exit at the end of the multiple doc test<commit_after>var tfidf = require('../tfidf');
var redis = require('redis').createClient();

function runTest() {
    var totalTermCount = 0;
    for (var prop in documents[documents.length - 1]) {
        if (documents[documents.length - 1].hasOwnProperty(prop)) {
            totalTermCount+=documents[documents.length-1][prop];
        }
    }
    tfidf.getScores(documents[documents.length-2], totalTermCount, function(scores) {

        tfidf.getScores(documents[documents.length-1], totalTermCount, function(scores) {
            var fail = false;
            console.log('score' + JSON.stringify(scores));
            for (var param in scores) {
                if (scores.hasOwnProperty(param)) {
                    if (param !== 'five' && 
                        scores[param] >= scores.five) {
                            fail = true;
                        }
                }
            }
            console.log('Test has pased: ' + (fail === false));
            process.exit();
        });
    });
}

var documents = [];
documents.push({
    'one': 1,
    'two': 1,
    'three': 1,
    'four': 1
});

documents.push({
    'one': 1,
    'two': 1,
    'three': 1,
    'four': 1,
    'five': 1
});

var keysServiced = 0;
for (var key in documents[documents.length - 1]) {
    if (documents[documents.length - 1].hasOwnProperty(key)) {
        (function(key) {
            redis.set(key, 0, function(err, res) {
                keysServiced++;
                if (keysServiced === Object.keys(documents[documents.length - 1]).length) {
                    return runTest();
                }
{'fraction_non_alphanumeric': 0.14890330552981154, 'fraction_numerical': 0.01235712079085573, 'mean_word_length': 1.8279475982532751, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6126126', 'n_tokens_mistral': 1025, 'n_tokens_neox': 933, 'n_words': 203}