<commit_before>var sys = require('sys'),
    http = require("http");
this.listeners = [];
this.listeners.push({'event': 'message.receive',
		     'func' : function(from, content, to, type, id) {
		       var that = this;
		       var res = /^def\s(.+)$/.exec(content);
                       if (res !== null) {
			 var google = http.createClient(80, "www.google.com");
			 var request = google.request("GET", "/search?q=define:"+res[1], {"host": "www.google.com"});
			 request.addListener('response', function (response) {
			   response.setBodyEncoding("utf8");
			   var buffer = '';
			   response.addListener("data", function (chunk) {
			     buffer += chunk.replace("\r", "");
			   });
			   response.addListener("end", function () {
			     var definition = /\<p\>\<li\>([^\<]+)\<br\>\<a href="\/url\?q=(http:\/\/en.wikipedia.org\/wiki\/[^&]+)&/.exec(buffer);
			     if (definition !== null) {
			       that.push(from, definition[1]+' '+definition[2]);
			     } else {
			       that.push(from, res[1] + " definition not found");
			     }
			   });
			 });
			 request.close();
                       }
                     }});<commit_msg>use querystring module and a better regex to grab definition in def plugin<commit_after>var sys = require('sys'),
    http = require("http");
this.listeners = [];
this.listeners.push({'event': 'message.receive',
		     'func' : function(from, content, to, type, id) {
		       var that = this;
		       var res = /^def\s(.+)$/.exec(content);
                       if (res !== null) {
			 var google = http.createClient(80, "www.google.com");
			 var query = "/search?"+require('querystring').stringify({q: 'define:'+res[1]});
			 var request = google.request("GET", query, {"host": "www.google.com"});
			 request.addListener('response', function (response) {
			   response.setBodyEncoding("utf8");
			   var buffer = '';
			   response.addListener("data", function (chunk) {
			     buffer += chunk.replace("\r", "");
			   });
			   response.addListener("end", function () {
			     var definition = /\<li\>([^\<]+)\<br\>\<a href="\/url\?q=(http:\/\/en.wikipedia.org\/wiki\/[^&]+)&/.exec(buffer);
			     if (definition !== null) {
			       that.push(from, definition[1]+' '+definition[2]);
			     } else {
			       that.push(from, res[1] + " definition not found");
			     }
			   });
			 });
			 request.close();
                       }
                     }});
{'fraction_non_alphanumeric': 0.21096003296250515, 'fraction_numerical': 0.0057684384013185, 'mean_word_length': 2.3124147339699865, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7609150', 'n_tokens_mistral': 857, 'n_tokens_neox': 710, 'n_words': 142}