<commit_before># encoding: utf-8

class UrbanDictionary
	include Cinch::Plugin

	match /u(?:r(?:ban)?)? (?:([1-7]{1}) )?(.+)/i, method: :urban

	def urban(m, number, word)
		return if ignore_nick(m.user.nick)

		begin
			number ||= 1

			url = "http://www.urbandictionary.com/define.php?term=#{CGI.escape(word)}"
			urban = Nokogiri::HTML(open(url))
			define = urban.search("//div[@class='meaning']")[number.to_i-1].text.gsub(/\s+/, ' ')

			if define.length > 250
				more = shorten_url("http://www.urbandictionary.com/define.php?term=#{CGI.escape(word)}")
				define = "#{define[0..250]}... Read more: #{more}"
			end

			m.reply "UrbanDictionary 06|\u000F #{word} 06|\u000F #{define}"
		rescue
			m.reply "UrbanDictionary 06|\u000F #{word} 06|\u000F Could not find definition"
		end
	end
end<commit_msg>Switched to UrbanDictionary API<commit_after># encoding: utf-8

class UrbanDictionary
	include Cinch::Plugin

	match /u(?:r(?:ban)?)? (?:([1-7]{1}) )?(.+)/i, method: :urban

	def urban(m, number, word)
		return if ignore_nick(m.user.nick)

		begin
			number ||= 1

			url = open("http://api.urbandictionary.com/v0/define?term=#{CGI.escape(word)}").read
			hashed = JSON.parse(url)

			define = hashed["list"][number.to_i-1]["definition"].gsub(/\s+/, ' ')
			more = shorten_url(hashed["list"][number.to_i-1]["permalink"])

			if define.length > 200
				define = "#{define[0..200]}..."
			end

			m.reply "UrbanDictionary 06|\u000F #{word} 06|\u000F #{more} 06|\u000F #{define}"
		rescue
			m.reply "UrbanDictionary 06|\u000F #{word} 06|\u000F Could not find definition"
		end
	end
end
{'fraction_non_alphanumeric': 0.20700437773608504, 'fraction_numerical': 0.045653533458411506, 'mean_word_length': 4.015673981191223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1549432', 'n_tokens_mistral': 724, 'n_tokens_neox': 610, 'n_words': 119}