classifier 1.4.0 → 1.4.1

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 +18 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c20227e9f55f35fe93f2cbb6e5fc132127159973da74d7af68d1680a25021e73
4
- data.tar.gz: ab8146db131a32b455b4e9b47dc3db7964e1e1a3bf9c69e953fdc6e6305eab89
3
+ metadata.gz: 100ebc0413bceeeb5148d4fed13de9cf9c9400016fc9f005d0d6a8f440ecf361
4
+ data.tar.gz: d8ff488e9fd84e28539b2546a1bb338deeecde8f24b0bcf312c04e2866137968
5
5
  SHA512:
6
- metadata.gz: 2d024e1d46b3529f7e328110e8b59161e0f6fa0d738b3de0d973073974ad69fd7d3bfb529d5a1b827a444266c14f5dff37630af2e522522d07d74f18324064eb
7
- data.tar.gz: 12fa59e6fc0f3e5ffb4fe1dc838b00ca529e630875729c78a3a0847bfdb6367856799c0f95831ecd75dbb36d0f4fad7fea2a6082083a965a5529d8bbf75a1542
6
+ metadata.gz: f41ee004b5d4c0a6cb18a9694fe1d69dcfdf0a7d4e3598086acf0c1bd786db43d5ef2a5b2d8438f1097eef0031bae7d8a7360a36fd0a7b28acad8f25fffb69a5
7
+ data.tar.gz: acefed9a7917ba3b1cdae5c23e0cb708533cf09b740a3b6d546ceabbd0d980abbfcce177fc89737a3a8afab3169eaa7f8e9ae99b8f870642a7ee68163064311d
@@ -139,5 +139,23 @@ module Classifier
139
139
  end
140
140
 
141
141
  alias append_category add_category
142
+
143
+ #
144
+ # Allows you to remove categories from the classifier.
145
+ # For example:
146
+ # b.remove_category "Spam"
147
+ #
148
+ # WARNING: Removing categories from a trained classifier will
149
+ # result in the loss of all training data for that category.
150
+ # Make sure you really want to do this before calling this method.
151
+ def remove_category(category)
152
+ category = category.prepare_category_name
153
+ raise StandardError, "No such category: #{category}" unless @categories.key?(category)
154
+
155
+ @categories.delete(category)
156
+ @category_counts.delete(category)
157
+ @category_word_count.delete(category)
158
+ @total_words -= @category_word_count[category].to_i
159
+ end
142
160
  end
143
161
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson