<commit_before>var net = require('net');

var HOST = '127.0.0.1';
var PORT = 13854;


/* Network Socket to Thinkgear Connector */

var client = new net.Socket();

client.connect(PORT, HOST, function() {

    client.write('{"appName": "brain.json", "appKey": "<KEY>", "format": "Json"}');

	// write session start
});


/* Receive Data */

client.on('data', function(data) {
	// save to database
	
	// * normal event
	// * blink event
	// * lost signal event
});


// Add a 'close' event handler for the client socket
client.on('close', function() {
	// write session end
});<commit_msg>Split json messages on carraige returns.<commit_after>var net = require('net');

var HOST = '127.0.0.1';
var PORT = 13854;


// TODO wrap this in a class with callbacks for handling the specific json events


/* Network Socket to Thinkgear Connector */

var client = new net.Socket();

client.connect(PORT, HOST, function() {

	client.write(JSON.stringify({"enableRawOutput": false, "format": "Json"}));
    client.write(JSON.stringify({"appName": "brain.json", "appKey": "<KEY>"}));

	// write session start
});


/* Receive Data */

client.on('data', function(data) {
	// save to database
	
	// For when two results come in the same packet
	var rows = data.toString().split('\r');

	// Remove trailing newline.
	rows.pop();

	// Process Rows
	rows.forEach( function(row) {
		console.log(JSON.parse(row.toString()));
	});

	// * normal event
	// * blink event
	// * lost signal event
});


// Add a 'close' event handler for the client socket
client.on('close', function() {
	// write session end
});
{'fraction_non_alphanumeric': 0.17391304347826086, 'fraction_numerical': 0.013862633900441084, 'mean_word_length': 3.537142857142857, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6775864', 'n_tokens_mistral': 535, 'n_tokens_neox': 502, 'n_words': 158}