<commit_before>/*jslint node: true, regexp: true */
'use strict';
var http = require("http"),
	url = require('url'),
	saneString,
	defaultResponse,
	findLexitagTerms;

/**
*	Finds a list of possible definitions of the term
*	@param {String} term: The term to define
*	@param {Function} callback($error, $definitions):
*	The function that is called when the definitions have been found
*	$error {Object}: An error object with the error encountered, or null
*	$definitions{Object}: An object of the form:
*	{
*		word {String}: The word to define
*		senses {Array}: An array containing the possible definitions. A definition is in the form
*		{
*			senseid {String}: A unique URL for the sense
*			explanation {String}: A short text explaining the definition
*		}
*	}
*/
exports.term = function (term, callback) {
	findLexitagTerms(term, function (json) {
		callback(null, json);
	});
};

findLexitagTerms =
	function (searchString, callback) {
		var body = '',
			url = 'http://lexitags.dyndns.org:8080/server/lexitags2/Semtags?data={"word": "',
			queryEnd = '"}';
		saneString(searchString, function (error, saneSearchString) {
			if (error) {
				console.log(error);
				callback(JSON.parse('{"senses": []}'));
			} else {
				var request = http.get(url + saneSearchString + queryEnd,
					function (response) {
						if (response.statusCode !== 200) {
							callback({});
						} else {
							response.on('data', function (chunk) {
								body += chunk;
							});
							response.on('end', function () {
								callback(JSON.parse(body));
							}).on('error', function () {<commit_msg>Uppdated url to lexitags server<commit_after>/*jslint node: true, regexp: true */
'use strict';
var http = require("http"),
	url = require('url'),
	saneString,
	defaultResponse,
	findLexitagTerms;

/**
*	Finds a list of possible definitions of the term
*	@param {String} term: The term to define
*	@param {Function} callback($error, $definitions):
*	The function that is called when the definitions have been found
*	$error {Object}: An error object with the error encountered, or null
*	$definitions{Object}: An object of the form:
*	{
*		word {String}: The word to define
*		senses {Array}: An array containing the possible definitions. A definition is in the form
*		{
*			senseid {String}: A unique URL for the sense
*			explanation {String}: A short text explaining the definition
*		}
*	}
*/
exports.term = function (term, callback) {
	findLexitagTerms(term, function (json) {
		callback(null, json);
	});
};

findLexitagTerms =
	function (searchString, callback) {
		var body = '',
			url = 'http://lexitags.dyndns.org/server/lexitags2/Semtags?data={"word": "',
			queryEnd = '"}';
		saneString(searchString, function (error, saneSearchString) {
			if (error) {
				console.log(error);
				callback(JSON.parse('{"senses": []}'));
			} else {
				var request = http.get(url + saneSearchString + queryEnd,
					function (response) {
						if (response.statusCode !== 200) {
							callback({});
						} else {
							response.on('data', function (chunk) {
								body += chunk;
							});
							response.on('end', function () {
								callback(JSON.parse(body));
							}).on('error', function () {
{'fraction_non_alphanumeric': 0.1453579243513598, 'fraction_numerical': 0.003751172241325414, 'mean_word_length': 3.685212298682284, 'pattern_counts': {'":': 4, '<': 3, '<?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': '1275774', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1010, 'n_words': 300}