bayes_on_redis 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.markdown +10 -0
  2. data/lib/bayes_on_redis.rb +3 -1
  3. metadata +3 -3
data/README.markdown CHANGED
@@ -8,6 +8,16 @@ Redis is perfect for building fast bayesian filter.
8
8
 
9
9
  ## Getting started
10
10
 
11
+ # Create instance of BayesOnRedis and pass your Redis information.
12
+ bor = BayesOnRedis.new(:redis_host => '127.0.0.1', :redis_port => 6379, :redis_db => 5)
13
+
14
+ # Teach it
15
+ bor.train "good", "sweet awesome kick-ass cool pretty smart"
16
+ bor.train "bad", "sucks lame boo death bankrupt loser sad"
17
+
18
+ # Then ask it to classify text.
19
+ bor.classify_for_human("awesome kick-ass ninja can still be lame.")
20
+
11
21
  ## Contributing
12
22
 
13
23
  [Fork the project](http://github.com/didip/bayes_on_redis) and send pull requests.
@@ -67,7 +67,9 @@ class BayesOnRedis
67
67
 
68
68
  # Incoming text is always downcased
69
69
  def count_occurance(text)
70
- text.downcase.split.inject(Hash.new(0)) do |container, word|
70
+ raise "input must be instance of String" unless text.is_a?(String)
71
+
72
+ text.to_s.downcase.split.inject(Hash.new(0)) do |container, word|
71
73
  container[word] += 1; container
72
74
  end
73
75
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bayes_on_redis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Didip Kerabat