kmeans 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ task :spec do
12
12
  end
13
13
  end
14
14
 
15
- if /^1\.9\./ =~ RUBY_VERSION
15
+ unless /^1\.8\./ =~ RUBY_VERSION
16
16
  desc "Run RSpec code examples with simplecov"
17
17
  task :simplecov do
18
18
  ENV['COVERAGE'] = "on"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -1,3 +1,8 @@
1
+ === 0.0.8 / 2013-03-19
2
+
3
+ * Correspond to string or nil included hash.
4
+
5
+
1
6
  === 0.0.7 / 2012-11-05
2
7
 
3
8
  * Correspond to illegal hash value.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "kmeans"
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["id774"]
12
- s.date = "2012-11-05"
12
+ s.date = "2013-03-19"
13
13
  s.description = "K-means clustering"
14
14
  s.email = "idnanashi@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -2,7 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  module Kmeans
5
- VERSION = "0.0.7"
5
+ VERSION = "0.0.8"
6
6
  require File.dirname(__FILE__) + "/kmeans/pair"
7
7
  require File.dirname(__FILE__) + "/kmeans/pearson"
8
8
  require File.dirname(__FILE__) + "/kmeans/cluster"
@@ -39,7 +39,7 @@ module Kmeans
39
39
 
40
40
  @word_counts.each {|url, counts|
41
41
  counts.each {|word, count|
42
- all_counts[word] << count
42
+ all_counts[word] << count.to_i
43
43
  }
44
44
  }
45
45
 
@@ -5,6 +5,8 @@
5
5
  #
6
6
  # Maintainer: id774 <idnanashi@gmail.com>
7
7
  #
8
+ # v1.1 3/14,2013
9
+ # Show ruby version.
8
10
  # v1.0 3/16,2012
9
11
  # First.
10
12
  ########################################################################
@@ -12,6 +14,7 @@
12
14
  kickstart() {
13
15
  export RACK_ROOT="."
14
16
  export RACK_ENV="test"
17
+ ruby -v
15
18
  }
16
19
 
17
20
  run_tests() {
@@ -69,6 +69,72 @@ describe Kmeans::Cluster do
69
69
  "piyo"=>1
70
70
  }
71
71
  }
72
+
73
+ @string_hash = {
74
+ "test01"=>
75
+ {"hoge"=>"0",
76
+ "fuga"=>"1",
77
+ "piyo"=>"0"
78
+ },
79
+ "test02"=>
80
+ {"hoge"=>"2",
81
+ "fuga"=>"1",
82
+ "piyo"=>"3"
83
+ },
84
+ "test03"=>
85
+ {"hoge"=>"3",
86
+ "fuga"=>"0",
87
+ "piyo"=>"1"
88
+ },
89
+ "test04"=>
90
+ {"hoge"=>"0",
91
+ "fuga"=>"2",
92
+ "piyo"=>"0"
93
+ },
94
+ "test05"=>
95
+ {"hoge"=>"4",
96
+ "fuga"=>"2",
97
+ "piyo"=>"3"
98
+ },
99
+ "test06"=>
100
+ {"hoge"=>"3",
101
+ "fuga"=>"1",
102
+ "piyo"=>"1"
103
+ }
104
+ }
105
+
106
+ @porous_hash = {
107
+ "test01"=>
108
+ {"hoge"=>"0",
109
+ "fuga"=>"1",
110
+ "piyo"=>nil
111
+ },
112
+ "test02"=>
113
+ {"hoge"=>"2",
114
+ "fuga"=>"1",
115
+ "piyo"=>"3"
116
+ },
117
+ "test03"=>
118
+ {"hoge"=>"3",
119
+ "fuga"=>nil,
120
+ "piyo"=>"1"
121
+ },
122
+ "test04"=>
123
+ {"hoge"=>nil,
124
+ "fuga"=>"2",
125
+ "piyo"=>nil
126
+ },
127
+ "test05"=>
128
+ {"hoge"=>"4",
129
+ "fuga"=>"2",
130
+ "piyo"=>"3"
131
+ },
132
+ nil=>
133
+ {"hoge"=>"3",
134
+ "fuga"=>"1",
135
+ nil=>"1"
136
+ },
137
+ }
72
138
  end
73
139
 
74
140
  context 'の Cluster クラスにおいて' do
@@ -111,5 +177,45 @@ describe Kmeans::Cluster do
111
177
  result.cluster.values.class.should be_equal Array
112
178
  end
113
179
  end
180
+
181
+ describe 'カウント部分が文字列な二次元ハッシュを渡しても' do
182
+ it "Kmeans::Cluster クラスが返却される" do
183
+ result = Kmeans::Cluster.new(@string_hash, {
184
+ :centroids => 5,
185
+ :loop_max => 10
186
+ })
187
+ result.class.should be_equal Kmeans::Cluster
188
+ end
189
+
190
+ it "ハッシュの配列が返却される (結果は実行ごとに異なる)" do
191
+ result = Kmeans::Cluster.new(@string_hash, {
192
+ :centroids => 5,
193
+ :loop_max => 10
194
+ })
195
+ result.make_cluster
196
+ result.cluster.class.should be_equal Hash
197
+ result.cluster.values.class.should be_equal Array
198
+ end
199
+ end
200
+
201
+ describe 'nil を含む二次元ハッシュを渡しても' do
202
+ it "Kmeans::Cluster クラスが返却される" do
203
+ result = Kmeans::Cluster.new(@porous_hash, {
204
+ :centroids => 5,
205
+ :loop_max => 10
206
+ })
207
+ result.class.should be_equal Kmeans::Cluster
208
+ end
209
+
210
+ it "ハッシュの配列が返却される (結果は実行ごとに異なる)" do
211
+ result = Kmeans::Cluster.new(@porous_hash, {
212
+ :centroids => 5,
213
+ :loop_max => 10
214
+ })
215
+ result.make_cluster
216
+ result.cluster.class.should be_equal Hash
217
+ result.cluster.values.class.should be_equal Array
218
+ end
219
+ end
114
220
  end
115
221
  end
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Kmeans do
6
6
  context 'のバージョンを参照した場合' do
7
7
  it "バージョンが正しく表示される" do
8
- expect = '0.0.7'
8
+ expect = '0.0.8'
9
9
  Kmeans.const_get(:VERSION).should be_true
10
10
  Kmeans.const_get(:VERSION).should == expect
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kmeans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
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: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2013-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber