classifier_atsukamoto 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/classifier/bayes.rb +5 -1
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71b29765988f479e71d6c4274ff44e9386080590
4
- data.tar.gz: 66296960bb987333968cadd0a2e916c036ebba7a
3
+ metadata.gz: aa3ac0b6e6de4f38df50922c6e69b7cc822b1ca2
4
+ data.tar.gz: 2c7157d3a7d85630a3b760e06582dcaa85e1ae31
5
5
  SHA512:
6
- metadata.gz: 2f8f37cd8d9466725c3d53a60da049cd7940780543251082900c46f9b76b3efcb63f406ecca09008e5f0caec4d664862c9778d78bb64a66d41d308b7a8aff9eb
7
- data.tar.gz: b57625657f662ec9daac8959d7c784bd9c6fe2f1faf2860c4405f6d714a85e73b2a7647f22a203528d83fc86beff2c0821102788002789bc89e850b7a4a24d74
6
+ metadata.gz: 8f536b77fa94db3aea1fe36cf98d7a28dd15db57b524b3510203aee7bb878be5a56cf31d1f32c8c55b99f11ea518a86dcea3d2e1f38cd339db80a046882f1d9e
7
+ data.tar.gz: cd010d2aa6f7c8c0cc4341b8567d1040a22f9b2a9f06bf57fb94d6fb313ff23bd0505b7c9d378650b4a85d132b07d1bae8be1562c37bf9517151334a67506632
@@ -87,7 +87,11 @@ class Bayes
87
87
  score[category.to_s] = 0
88
88
 
89
89
  # total = category_words.values.inject(0) {|sum, element| sum+element}
90
- total = category_words.inject(0) { |sum, element| sum + element }
90
+ begin
91
+ total = category_words.inject(0) { |sum, element| sum + element }
92
+ rescue
93
+ raise "Bayes needs to be trained before trying to classify"
94
+ end
91
95
 
92
96
  text.word_hash(@stemmer).each do |word, count|
93
97
  #s = category_words.has_key?(word) ? category_words[word] : 0.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classifier_atsukamoto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
@@ -69,3 +69,4 @@ signing_key:
69
69
  specification_version: 4
70
70
  summary: Classifier with Redis
71
71
  test_files: []
72
+ has_rdoc: