recommendify 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/ext/recommendify.c CHANGED
@@ -57,6 +57,7 @@ int main(int argc, char **argv){
57
57
  redisPrefix = argv[2];
58
58
  itemID = argv[3];
59
59
  redis_addr.host[0] = 0;
60
+ redis_addr.port = 0;
60
61
 
61
62
  /* configure redis location */
62
63
  if(argc > 4){
@@ -86,13 +87,20 @@ int main(int argc, char **argv){
86
87
  return 1;
87
88
  }
88
89
 
90
+
89
91
  /* get item count */
90
92
  reply = redisCommand(c,"HGET %s:items %s", redisPrefix, itemID);
91
- itemCount = atoi(reply->str);
93
+
94
+ if(reply->str){
95
+ itemCount = atoi(reply->str);
96
+ } else {
97
+ itemCount = 0;
98
+ }
99
+
92
100
  freeReplyObject(reply);
93
101
 
94
102
  if(itemCount == 0){
95
- printf("item count is zero\n");
103
+ printf("exit: item count is zero\n");
96
104
  return 0;
97
105
  }
98
106
 
@@ -19,11 +19,10 @@ module Recommendify::CCMatrix
19
19
  end
20
20
 
21
21
  def add_single(set_id, item_id, other_item_ids)
22
- # todo: add single item to set after set was added (incrementally)
23
- # item_count_incr(item_id)
24
- # other_item_ids.each do |other_item|
25
- # @ccmatrix.incr(item_id, other_idem)
26
- # end
22
+ item_count_incr(item_id)
23
+ other_item_ids.each do |other_item|
24
+ @ccmatrix.incr(item_id, other_item)
25
+ end
27
26
  end
28
27
 
29
28
  def all_items
data/recommendify.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "recommendify"
6
- s.version = "0.3.2"
6
+ s.version = "0.3.3"
7
7
  s.date = Date.today.to_s
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Paul Asmuth"]
data/spec/base_spec.rb CHANGED
@@ -161,6 +161,11 @@ describe Recommendify::Base do
161
161
  sm.for("fnorditem").should == []
162
162
  end
163
163
 
164
+ it "should not call split on nil when retrieving a non-existent item (return an empty array)" do
165
+ sm = Recommendify::Base.new
166
+ sm.for("NONEXISTENT").should == []
167
+ end
168
+
164
169
  end
165
170
 
166
171
  describe "delete_item!" do
@@ -19,8 +19,22 @@ share_examples_for Recommendify::CCMatrix do
19
19
  @matrix.ccmatrix["foo", "fnord"].should == 1
20
20
  end
21
21
 
22
- it "should increment all item<->item paris on single item addition"
23
- it "should increment the item count on single item addition"
22
+ it "should increment all item<->item paris on single item addition" do
23
+ @matrix.ccmatrix["bar", "fnord"] = 2
24
+ @matrix.add_single("user123", "fnord", ["foo", "bar"])
25
+ @matrix.ccmatrix["bar", "fnord"].should == 3
26
+ @matrix.ccmatrix["foo", "fnord"].should == 1
27
+ end
28
+
29
+ it "should increment the item count on single item addition" do
30
+ @matrix.send(:item_count_incr, "fnordfnord")
31
+ @matrix.send(:item_count_incr, "fnordfnord")
32
+ @matrix.send(:item_count_incr, "foofnord")
33
+ @matrix.add_single("user123", "fnordfnord", ["foofnord", "barfnord"])
34
+ @matrix.send(:item_count, "foofnord").should == 1
35
+ @matrix.send(:item_count, "barfnord").should == 0
36
+ @matrix.send(:item_count, "fnordfnord").should == 3
37
+ end
24
38
 
25
39
  it "should calculate all item<->item pairs (3)" do
26
40
  res = @matrix.send(:all_pairs, ["foo", "bar", "fnord"])
@@ -88,8 +88,6 @@ describe Recommendify::SimilarityMatrix do
88
88
  @matrix["item_fnord"].should == {"item_blubb" => 0.6, "item_foo" => 0.4}
89
89
  end
90
90
 
91
- it "should not call split on nil when retrieving a non-existent item (return an empty array)"
92
-
93
91
  end
94
92
 
95
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recommendify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &11718500 !ruby/object:Gem::Requirement
16
+ requirement: &83607540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *11718500
24
+ version_requirements: *83607540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &11717900 !ruby/object:Gem::Requirement
27
+ requirement: &83607300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *11717900
35
+ version_requirements: *83607300
36
36
  description: Recommendify is a distributed, incremental item-based recommendation
37
37
  engine for binary input ratings. It's based on ruby and redis and uses an approach
38
38
  called "Collaborative Filtering"
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 1.8.17
103
+ rubygems_version: 1.8.6
104
104
  signing_key:
105
105
  specification_version: 3
106
106
  summary: ruby/redis based recommendation engine (collaborative filtering)
@@ -115,3 +115,4 @@ test_files:
115
115
  - spec/similarity_matrix_spec.rb
116
116
  - spec/sparse_matrix_spec.rb
117
117
  - spec/spec_helper.rb
118
+ has_rdoc: