<commit_before>var fs = require("fs");
var parse = require("csv-parse");
var assert = require("assert");
var classifier = require("../logistical.js");

describe('Logistical', function(){
  var subject;
  var contents;
  var training;
  var verfication;

  before(function(done){
    fs.readFile(__dirname + '/data/verification.csv', function (readError, data) {
      if (readError) throw readError;

      parse(data,{auto_parse: true}, function(parseError, output) {
        if (parseError) throw parseError;

        contents = output;
        verification = contents.slice(0, 100);
        training = contents.slice(100, contents.length - 1);
        done();
      });
    });

  });

  beforeEach( function(done){
    subject = new classifier();
    done();
  });


  describe('#logit', function() {
    it('correctly calculates the logit function', function(){
      var result = 0.5;
      var value = 0.0;
      assert.equal(result, subject.logit(value));
    });
  });

  describe('#classify', function(){
    it('correctly classifies test data', function(){
      for(var i=0; i < verification.length; i++) {
        var end = verification[i].length - 1;
        var test = verification[i].slice(0, end - 1);
        var result = verification[i][end];

        assert.equal(result, subject.classify(test));
      }
    });
  });
});<commit_msg>prefer the shorter syntax and clear test case description<commit_after>var fs = require("fs");
var parse = require("csv-parse");
var assert = require("assert");
var classifier = require("../logistical.js");

describe('Logistical', function(){
  var subject;
  var contents;
  var training;
  var verfication;

  before(function(done){
    fs.readFile(__dirname + '/data/verification.csv', function (readError, data) {
      if (readError) throw readError;

      parse(data,{auto_parse: true}, function(parseError, output) {
        if (parseError) throw parseError;

        contents = output;
        verification = contents.slice(0, 100);
        training = contents.slice(100, contents.length - 1);
        done();
      });
    });

  });

  beforeEach( function(done){
    subject = new classifier();
    done();
  });

  /* Test computation of the logistic function */
  describe('#logistic', function() {
    it(' validates function works for known values', function(){
      assert.equal(0.5, subject.logistic(0.0));
    });
  });

  describe('#classify', function(){
    it('correctly classifies test data', function(){
      for(var i=0; i < verification.length; i++) {
        var end = verification[i].length - 1;
        var test = verification[i].slice(0, end - 1);
        var result = verification[i][end];

        assert.equal(result, subject.classify(test));
      }
    });
  });
});
{'fraction_non_alphanumeric': 0.15736040609137056, 'fraction_numerical': 0.011602610587382161, 'mean_word_length': 3.0573529411764704, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1843198', 'n_tokens_mistral': 837, 'n_tokens_neox': 789, 'n_words': 206}