<commit_before>// (c) 2011 <NAME>
// This code is licensed under the MIT license; see LICENSE.txt for details.

// This script handles the following functions:
//     ~calc|eval|math expression - evaluates expression as javascript within an empty sandbox; can be used like a calculator
//     When some apparent math is found (matching numbers, parentheses and math operators), tries to solve it and says the answer;
//         this way, if someone says a sentence with some math in it, the bot will solve the math for them. How helpful!

var vm = require('vm');
var exec = require('child_process').exec;

listen(/PRIVMSG [^ ]+ :~(calc|eval|math) (.*)$/i, function(match, data, replyTo) {
	var child = exec('node scripts/calc.js.child',
		{ encoding: 'ascii',
			timeout: 500 },
		function (error, stdout, stderr) {
			if(error != null) {
				irc.privmsg(replyTo, stdout);
			} else {
				irc.privmsg(replyTo, "Result: "+stdout);
			}
		}
	);
	child.stdin.end(match[2]);
});

listen(/PRIVMSG [^ ]+ :(?!~(calc|eval|math)).*?([()\d]+(?:[()+\-*\/][0-9]+[()]*)+)/i, function(match, data, replyTo) {
	try {
		var result = vm.runInNewContext(match[2]);
		var numeric = parseFloat(result);
		irc.privmsg(replyTo, match[2]+" = "+numeric);
	} catch(err) {
		console.log(err);
	}
});<commit_msg>Removed the automatic calculation feature<commit_after>// (c) 2011 <NAME>
// This code is licensed under the MIT license; see LICENSE.txt for details.

// This script handles the following functions:
//     ~calc|eval|math expression - evaluates expression as javascript within an empty sandbox; can be used like a calculator
//     When some apparent math is found (matching numbers, parentheses and math operators), tries to solve it and says the answer;
//         this way, if someone says a sentence with some math in it, the bot will solve the math for them. How helpful!
//         (edit: it ended up being more annoying than helpful, and has been commented out)

var vm = require('vm');
var exec = require('child_process').exec;

listen(/PRIVMSG [^ ]+ :~(calc|eval|math) (.*)$/i, function(match, data, replyTo) {
	var child = exec('node scripts/calc.js.child',
		{ encoding: 'ascii',
			timeout: 500 },
		function (error, stdout, stderr) {
			if(error != null) {
				irc.privmsg(replyTo, stdout);
			} else {
				irc.privmsg(replyTo, "Result: "+stdout);
			}
		}
	);
	child.stdin.end(match[2]);
});

/* this feature ended up being kinda annoying
listen(/PRIVMSG [^ ]+ :(?!~(calc|eval|math)).*?([()\d]+(?:[()+\-*\/][0-9]+[()]*)+)/i, function(match, data, replyTo) {
	try {
		var result = vm.runInNewContext(match[2]);
		var numeric = parseFloat(result);
		irc.privmsg(replyTo, match[2]+" = "+numeric);
	} catch(err) {
		console.log(err);
	}
});
*/
{'fraction_non_alphanumeric': 0.16721431179262505, 'fraction_numerical': 0.008762322015334063, 'mean_word_length': 3.849557522123894, 'pattern_counts': {'":': 0, '<': 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': '5167834', 'n_tokens_mistral': 958, 'n_tokens_neox': 873, 'n_words': 285}