bayes_on_redis 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.markdown +8 -4
  2. data/lib/bayes_on_redis.rb +4 -4
  3. metadata +3 -3
data/README.markdown CHANGED
@@ -1,10 +1,14 @@
1
- # bayes_on_redis
1
+ # What is BayesOnRedis?
2
2
 
3
3
  Bayesian classifier on top of Redis
4
4
 
5
5
  ## Why on Redis?
6
6
 
7
- Redis is perfect for building fast bayesian filter.
7
+ Because of its persistent but also in-memory data structures, Redis is perfect for weeks of machine learning.
8
+
9
+ ## How to install?
10
+
11
+ gem install bayes_on_redis
8
12
 
9
13
  ## Getting started
10
14
 
@@ -16,8 +20,8 @@ Redis is perfect for building fast bayesian filter.
16
20
  bor.train "bad", "sucks lame boo death bankrupt loser sad"
17
21
 
18
22
  # Then ask it to classify text.
19
- bor.classify_for_human("awesome kick-ass ninja can still be lame.")
23
+ bor.classify("awesome kick-ass ninja can still be lame.")
20
24
 
21
25
  ## Contributing
22
26
 
23
- [Fork the project](http://github.com/didip/bayes_on_redis) and send pull requests.
27
+ [Fork http://github.com/didip/bayes_on_redis](http://github.com/didip/bayes_on_redis) and send pull requests.
@@ -43,7 +43,7 @@ class BayesOnRedis
43
43
  end
44
44
  alias_method :unlearn, :untrain
45
45
 
46
- def classify(text)
46
+ def score(text)
47
47
  scores = {}
48
48
 
49
49
  @redis.smembers(CATEGORIES_KEY).each do |category|
@@ -63,8 +63,8 @@ class BayesOnRedis
63
63
  return scores
64
64
  end
65
65
 
66
- def classify_for_human(text)
67
- (classify(text).sort_by { |score| -score[1] })[0][0] # [0][0] -> first score, get the key
66
+ def classify(text)
67
+ (score(text).sort_by { |score| -score[1] })[0][0] # [0][0] -> first score, get the key
68
68
  end
69
69
 
70
70
  private
@@ -76,7 +76,7 @@ class BayesOnRedis
76
76
  def count_occurance(text='')
77
77
  raise "input must be instance of String" unless text.is_a?(String)
78
78
 
79
- text_chunks = text.downcase.gsub(ONE_OR_TWO_WORDS_RE, '').gsub(NON_ALPHANUMERIC_AND_NON_DOT_RE, ' ').gsub(@stopwords.to_re, '').split
79
+ text_chunks = text.downcase.gsub(ONE_OR_TWO_WORDS_RE, '').gsub(NON_ALPHANUMERIC_AND_NON_DOT_RE, ' ').gsub(@stopwords.to_re, '').gsub(/\./, '').split
80
80
  text_chunks.inject(Hash.new(0)) do |container, word|
81
81
  container[word] += 1; container
82
82
  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: 21
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 9
10
+ version: 0.1.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Didip Kerabat