<commit_before>var Define = function() {
	//Constructor
	this.apiEndpoint = 'http://api.wordnik.com:80/v4/word.json/\
{word}/definitions?\
limit=200\
&includeRelated=true\
&useCanonical=false\
&includeTags=false\
&api_key={apiKey}';
	this.words = {};
	// keep words in cache for 2 minutes.
	this.wordTimeout = 120000;
	this.noMatchForWordMsg = 'I can\'t find a definition for this word :/';
}

Define.prototype = {
	http: require('http'),
	debug: global.config.get('debug'),
	apiKey: global.config.get('wordnik_api'),
	handle: function(from, chan, message) {
		var irc = global.irc;
		var matches;
		if (matches = message.trimRight().match(/^!([\S]*) (.*)$/i)) {
			if (matches[1] == 'define') {
				var self = this;
				this.getWordDefinition(matches[2].toLowerCase(),
				function(wordDefinition){
					irc.client.say(chan, wordDefinition.word + ': ' + wordDefinition.definition);
				},
				function(error){
					if (self.debug == 'true')
						console.log('[\033[31mDefine Module\033[0m]: ' + error);
					irc.client.say(chan, self.noMatchForWordMsg);
				});
			}
		}
	},
	getWordDefinitionFromCache: function(word, OnSuccess)
	{
		if (this.words[word] === undefined)
			return (false);
		OnSuccess({word: word, definition:this.words[word]["definition"][this.words[word]["i"]]});
		this.words[word]["i"] += this.words[word]["i"] >= (this.words[word]["definition"].length-1) ? -this.words[word]["i"] : 1;
		return (true);
	},
	getWordDefinitionFromAPI: function(word, OnSuccess, OnError)
	{
		var self = this;
		this.http.get(this.apiEndpoint.replace("{word}", matches[2].trim()).replace("{apiKey}", this.apiKey), function(res) {
			res.setEncoding('utf8');
			var body = '';
			res.on('data', function(chunk) {
				body += chunk;
			});

			res.on('end', function(){
				var definitions = {};
				try {
					definitions = JSON.parse(body);
				} catch (ex) {
					OnError(ex);
					return;
				}
				if (definitions.length == 0)
					OnError('No match for: ' + word);
				else
				{
					self.setWordDefinitions(word, definitions);
					self.getWordDefinitionFromCache(word, OnSuccess)
				}
			});
<commit_msg>Fixed reference to non-existent matches in function<commit_after>var Define = function() {
	//Constructor
	this.apiEndpoint = 'http://api.wordnik.com:80/v4/word.json/\
{word}/definitions?\
limit=200\
&includeRelated=true\
&useCanonical=false\
&includeTags=false\
&api_key={apiKey}';
	this.words = {};
	// keep words in cache for 2 minutes.
	this.wordTimeout = 120000;
	this.noMatchForWordMsg = 'I can\'t find a definition for this word :/';
}

Define.prototype = {
	http: require('http'),
	debug: global.config.get('debug'),
	apiKey: global.config.get('wordnik_api'),
	handle: function(from, chan, message) {
		var irc = global.irc;
		var matches;
		if (matches = message.trimRight().match(/^!([\S]*) (.*)$/i)) {
			if (matches[1] == 'define') {
				var self = this;
				this.getWordDefinition(matches[2].toLowerCase(),
				function(wordDefinition){
					irc.client.say(chan, wordDefinition.word + ': ' + wordDefinition.definition);
				},
				function(error){
					if (self.debug == 'true')
						console.log('[\033[31mDefine Module\033[0m]: ' + error);
					irc.client.say(chan, self.noMatchForWordMsg);
				});
			}
		}
	},
	getWordDefinitionFromCache: function(word, OnSuccess)
	{
		if (this.words[word] === undefined)
			return (false);
		OnSuccess({word: word, definition:this.words[word]["definition"][this.words[word]["i"]]});
		this.words[word]["i"] += this.words[word]["i"] >= (this.words[word]["definition"].length-1) ? -this.words[word]["i"] : 1;
		return (true);
	},
	getWordDefinitionFromAPI: function(word, OnSuccess, OnError)
	{
		var self = this;
		this.http.get(this.apiEndpoint.replace("{word}", word.trim()).replace("{apiKey}", this.apiKey), function(res) {
			res.setEncoding('utf8');
			var body = '';
			res.on('data', function(chunk) {
				body += chunk;
			});

			res.on('end', function(){
				var definitions = {};
				try {
					definitions = JSON.parse(body);
				} catch (ex) {
					OnError(ex);
					return;
				}
				if (definitions.length == 0)
					OnError('No match for: ' + word);
				else
				{
					self.setWordDefinitions(word, definitions);
					self.getWordDefinitionFromCache(word, OnSuccess)
				}
			});

{'fraction_non_alphanumeric': 0.18785178236397748, 'fraction_numerical': 0.013367729831144466, 'mean_word_length': 3.8029279279279278, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1601545', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1466, 'n_words': 266}