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 +10 -2
- data/lib/recommendify/cc_matrix.rb +4 -5
- data/recommendify.gemspec +1 -1
- data/spec/base_spec.rb +5 -0
- data/spec/cc_matrix_shared.rb +16 -2
- data/spec/similarity_matrix_spec.rb +0 -2
- metadata +7 -6
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
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
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
|
data/spec/cc_matrix_shared.rb
CHANGED
@@ -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
|
-
|
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"])
|
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.
|
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: &
|
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: *
|
24
|
+
version_requirements: *83607540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
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: *
|
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.
|
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:
|