classifier 1.4.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/lib/classifier/bayes.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 100ebc0413bceeeb5148d4fed13de9cf9c9400016fc9f005d0d6a8f440ecf361
|
4
|
+
data.tar.gz: d8ff488e9fd84e28539b2546a1bb338deeecde8f24b0bcf312c04e2866137968
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41ee004b5d4c0a6cb18a9694fe1d69dcfdf0a7d4e3598086acf0c1bd786db43d5ef2a5b2d8438f1097eef0031bae7d8a7360a36fd0a7b28acad8f25fffb69a5
|
7
|
+
data.tar.gz: acefed9a7917ba3b1cdae5c23e0cb708533cf09b740a3b6d546ceabbd0d980abbfcce177fc89737a3a8afab3169eaa7f8e9ae99b8f870642a7ee68163064311d
|
data/lib/classifier/bayes.rb
CHANGED
@@ -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
|