reclassifier 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/reclassifier/bayes.rb +1 -1
- data/lib/reclassifier/version.rb +1 -1
- data/spec/bayes_spec.rb +11 -0
- metadata +2 -2
data/lib/reclassifier/bayes.rb
CHANGED
@@ -105,7 +105,7 @@ class Reclassifier::Bayes
|
|
105
105
|
# => :uninteresting
|
106
106
|
#
|
107
107
|
def classify(text)
|
108
|
-
calculate_scores(text).max_by {|classification| classification[1]}[0]
|
108
|
+
calculate_scores(text.to_s).max_by {|classification| classification[1]}[0]
|
109
109
|
end
|
110
110
|
|
111
111
|
# Provides a list of classification names
|
data/lib/reclassifier/version.rb
CHANGED
data/spec/bayes_spec.rb
CHANGED
@@ -13,6 +13,17 @@ describe Reclassifier::Bayes do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe 'classify' do
|
17
|
+
it 'should handle a nil text gracefully' do
|
18
|
+
classifier = Reclassifier::Bayes.new([:in_china, :not_in_china])
|
19
|
+
|
20
|
+
classifier.train(:in_china, 'Chinese Macao')
|
21
|
+
classifier.train(:not_in_china, 'Tokyo Japan Chinese')
|
22
|
+
|
23
|
+
classifier.classify(nil)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
describe "classifications" do
|
17
28
|
it "should return the classifications" do
|
18
29
|
classifier = Reclassifier::Bayes.new([:interesting, :uninteresting])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reclassifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|