bayesball 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Bayesball
2
2
 
3
- TODO: Write a gem description
3
+ Bayesball is a naive Bayes classifier with support for in memory and mongo
4
+ persistence.
4
5
 
5
6
  ## Installation
6
7
 
@@ -18,7 +19,13 @@ Or install it yourself as:
18
19
 
19
20
  ## Usage
20
21
 
21
- TODO: Write usage instructions here
22
+ ```ruby
23
+ classifier = Bayesball::Classifier.new
24
+
25
+ classifier.train 'basketball', 'dunk the ball'
26
+
27
+ classifier.classify 'Slam Dunk!' #=> "basketball"
28
+ ```
22
29
 
23
30
  ## Contributing
24
31
 
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require "bundler/gem_tasks"
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
+ puts ENV['TERM']
5
6
  t.libs = ['spec', 'lib']
6
- t.test_files = Dir['spec/**/*_spec.rb']
7
+ t.pattern = 'spec/**/*_spec.rb'
7
8
  end
@@ -36,7 +36,7 @@ module Bayesball
36
36
 
37
37
  def classify(payload)
38
38
  s = score(payload)
39
- s.sort_by{|k,v| v}.reverse[0][0]
39
+ s.sort_by{|_,v| v}.map{|k,_| k}.reverse.first
40
40
  end
41
41
  end
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module Bayesball
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bayesball::Classifier do
4
- let(:subject) { Bayesball::Classifier.new(Bayesball::Persistence::Mongo.new(MONGO_URI)) }
4
+ let(:subject) { Bayesball::Classifier.new }
5
5
 
6
6
  it 'should do word counts' do
7
7
  result = subject.word_counts('Hello, friend. Hello!')
@@ -47,4 +47,8 @@ describe Bayesball::Classifier do
47
47
  subject.classify('Hitting a ball made of rubber').must_equal 'racquetball'
48
48
  subject.classify('The winning team is kicking butt. They always make the ball go in the hoop every time').must_equal 'basketball'
49
49
  end
50
+
51
+ it 'should return nil if cannot classify' do
52
+ subject.classify('there are no topics').must_be_nil
53
+ end
50
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bayesball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-09 00:00:00.000000000 Z
12
+ date: 2012-04-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A bayes classifier
15
15
  email:
@@ -48,7 +48,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  segments:
50
50
  - 0
51
- hash: -3818961451437177514
51
+ hash: -4130593485830818059
52
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  segments:
59
59
  - 0
60
- hash: -3818961451437177514
60
+ hash: -4130593485830818059
61
61
  requirements: []
62
62
  rubyforge_project:
63
63
  rubygems_version: 1.8.18