classifier 1.4.0 → 1.4.2

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 +19 -0
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c20227e9f55f35fe93f2cbb6e5fc132127159973da74d7af68d1680a25021e73
4
- data.tar.gz: ab8146db131a32b455b4e9b47dc3db7964e1e1a3bf9c69e953fdc6e6305eab89
3
+ metadata.gz: 8c8010bf5648dd9ca16e4c15e44c627c295978440a15e8ce2bd8314a91a050f7
4
+ data.tar.gz: 168a80242021c3153b405a7102e480a76a66916eedb628e3d90a150bbe3f69a3
5
5
  SHA512:
6
- metadata.gz: 2d024e1d46b3529f7e328110e8b59161e0f6fa0d738b3de0d973073974ad69fd7d3bfb529d5a1b827a444266c14f5dff37630af2e522522d07d74f18324064eb
7
- data.tar.gz: 12fa59e6fc0f3e5ffb4fe1dc838b00ca529e630875729c78a3a0847bfdb6367856799c0f95831ecd75dbb36d0f4fad7fea2a6082083a965a5529d8bbf75a1542
6
+ metadata.gz: a3fb835c78cfa325c5008a88e3202a92df188cc0a870ce7e09a333040f2bd272c7be15747d5c7d055edfbeba6fedf7a5322d05b36e1da3bef53ca05696b12303
7
+ data.tar.gz: cd3dd6304aa20a2eb251db1e6d3c5f28cd93860ca463bdc6b65af1dca7d42ee037e561d2c41ad3f8d0203fd2ba2900203e56e6fed8f0bda54f525b62cb72cc4c
@@ -139,5 +139,24 @@ 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
+ @total_words -= @category_word_count[category].to_i
156
+
157
+ @categories.delete(category)
158
+ @category_counts.delete(category)
159
+ @category_word_count.delete(category)
160
+ end
142
161
  end
143
162
  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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mutex_m
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement