Sha256: 89d33dad2c012f32357032f684bdb4b62bf351d8517ae0cf218c93195e891c06

Contents?: true

Size: 1010 Bytes

Versions: 17

Compression:

Stored size: 1010 Bytes

Contents

require File.dirname(__FILE__) + '/../test_helper'
class BayesianTest < Test::Unit::TestCase
	def setup
		@classifier = Classifier::Bayes.new 'Interesting', 'Uninteresting'
	end
	
	def test_good_training
		assert_nothing_raised { @classifier.train_interesting "love" }
	end

	def test_bad_training
		assert_raise(StandardError) { @classifier.train_no_category "words" }
	end
	
	def test_bad_method
		assert_raise(NoMethodError) { @classifier.forget_everything_you_know "" }
	end
	
	def test_categories
		assert_equal ['Interesting', 'Uninteresting'].sort, @classifier.categories.sort
	end

	def test_add_category
		@classifier.add_category 'Test'
		assert_equal ['Test', 'Interesting', 'Uninteresting'].sort, @classifier.categories.sort
	end

	def test_classification
		@classifier.train_interesting "here are some good words. I hope you love them"
		@classifier.train_uninteresting "here are some bad words, I hate you"
		assert_equal 'Uninteresting', @classifier.classify("I hate bad words and you")
	end
end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
otherinbox-classifier-1.3.1.1 test/bayes/bayesian_test.rb
classifier-fork-1.3.4 test/bayes/bayesian_test.rb
classifier-1.3.4 test/bayes/bayesian_test.rb
classifier_atsukamoto-0.0.5 test/bayes/bayesian_test.rb
classifier_atsukamoto-0.0.4 test/bayes/bayesian_test.rb
classifier_atsukamoto-0.0.3 test/bayes/bayesian_test.rb
classifier_atsukamoto-0.0.2 test/bayes/bayesian_test.rb
classifier_atsukamoto-0.0.1 test/bayes/bayesian_test.rb
otherinbox-classifier-1.3.1.2.20121218.2 test/bayes/bayesian_test.rb
otherinbox-classifier-1.3.1.2.20121218 test/bayes/bayesian_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/classifier-1.3.3/test/bayes/bayesian_test.rb
classifier-1.3.3 test/bayes/bayesian_test.rb
classifier-1.3.2 test/bayes/bayesian_test.rb
secobarbital-classifier-1.3.1.1 test/bayes/bayesian_test.rb
classifier-1.2.0 test/bayes/bayesian_test.rb
classifier-1.3.0 test/bayes/bayesian_test.rb
classifier-1.3.1 test/bayes/bayesian_test.rb